Tell us what’s happening:
If I console.log() arr it is only showing an array which i believe should only be the first element of the argument object. Subscript of arr only gives me specific elements within that array. I have tried converting the arr to an array, but again the only thing to convert is the array, not the other arguments that are supposed to be there. Must be missing something here. Thanks for your help.
Your code so far
function destroyer(arr) {
console.log(arr[2]);
let retArr = [];
retArr = (Array.prototype.slice.call(arr));
console.log(retArr);
retArr = Array.from(arr);
console.log(retArr);
for(let i = 1; i < arr.length; i++){
for(let j = 0; j < retArr.length; j++){
if(arr[i] === retArr[j]){
console.log(arr[i]);
retArr.splice(j,1);
console.log(retArr);
}
}
}
return retArr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Your browser information:
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0
.
Challenge: Seek and Destroy
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/seek-and-destroy