0

I need help writing a code that will remove all elements from the initial array that are of the same value as these arguments.

I have some code but I'm not sure if it's valid for what I'm trying to do. Some advice rather than just the answer would be nice. function destroyer(arr) { var args = Array.prototype.slice.call(arguments[0], arguments[1]); return args; } destroyer([1, 2, 3, 1, 2, 3], 2, 3);

15th Jul 2017, 11:33 AM
Timothy
2 ответов
+ 2
// I suppose you want to use destroyer() with first argument as array to transform it (by returnin new one, without modifying the original array) by slicing from second argument as index of start item upon third argument as index of end item (not included) function destroyer(arr) { var args = Array.prototype.slice.call(arguments[0], arguments[1],arguments[2]); // you're using 3 arguments in your later call ^^ return args; } // you need to store (or directly use) the returned value: var result = destroyer([1, 2, 3, 1, 2, 3], 2, 3); alert(result);
15th Jul 2017, 11:50 AM
visph
visph - avatar
0
Thanks for the help. I think I know what to do now.
15th Jul 2017, 12:04 PM
Timothy