about | help | code help+videos | done | prefs |
Write a method that accepts an original array called 'orig' and an array of numbers that need to be replaced in an array called 'replace'. Each time any of the numbers in 'replace' appears in 'orig', replace it with 'replaceVal'. It IS possible that 'replaceVal' will be the same value as one of the values in 'replace'. If that happens, use zero as the 'replaceVal'. Look at the test data for examples. dec16_2019_HL_replace([500, 400, 750, 1200], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], -500) → [500, 400, 750, 1200] dec16_2019_HL_replace([15, 20, 25, 3, 4, 5, 2], [25, 5, 2], 10000) → [15, 20, 10000, 3, 4, 10000, 10000] dec16_2019_HL_replace([5, 8, 2, 1, 3, 7, 15, 9, 4, 22], [7, 1, 8], 50) → [5, 50, 2, 50, 3, 50, 15, 9, 4, 22] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy