Hi all,
Below my solution. It is actually working but I do not understand how arguments
could be handled as an array (length method) within the function.
function destroyer(arr) {
// Remove all the values
let newArr = [...arr];
for(let i = 1; i < arguments.length; i++){
newArr = newArr.filter((x) => (x != arguments[i]));
}
return newArr;
}
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));
If I create a similar object and try to get the length of it I get undefined
> myObj = { '0': 1, '1': 1, '2': 2, '3': 3, '4': 4 }
{ '0': 1, '1': 1, '2': 2, '3': 3, '4': 4 }
> myObj.length
undefined
Any explanation is very welcome.
Regards,