about | help | code help+videos | done | prefs |
Write a method that returns the integer array that is passed in, except that every-(n)th number has been replaced with the value of 'val'. So keep up to the (n-1)th number, then replace the next one with val, and keep going like that. There can be any number of numbers in the array. Look at the test data for examples. sept26_2019_P1SLHL_replaceEveryNth([5, 4, 3, 2, 1], 2, 0) → [5, 0, 3, 0, 1] sept26_2019_P1SLHL_replaceEveryNth([6, 10, 20, 50, -3, -9, 12, 400], 4, -1000) → [6, 10, 20, -1000, -3, -9, 12, -1000] sept26_2019_P1SLHL_replaceEveryNth([1, 2, 3, 4, 5, 6, 7, 8, 9], 5, 0) → [1, 2, 3, 4, 0, 6, 7, 8, 9] ...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