Remove value

Report a typo

Sometimes it's important to avoid mutating an array. So if we want to remove elements we can't use splice().

Make a function called newRemove that can delete elements but doesn't modify the existing array. It should accept the array, a positive index number at which to start deleting, and the number of elements to remove.

Tip: You can use concat() and slice().

Sample Input 1:

[ 'red', 'yellow', 'green', 'blue' ]
0
2

Sample Output 1:

[ 'green', 'blue' ]
Write a program in JavaScript
function newRemove(array, index, n) {
return ...; // Enter your code in place of ... and use slice and concat
}
___

Create a free account to access the full topic