Tell us what’s happening:
Describe your issue in detail here.
i’m trying to understand the double loop throughly , but i cant seem understand why i cant loop through 1 - 5.
i get the length is 0 - 4, but i couldnt get it how to get loop to the 5th.
function argu(arr1, arr2){
for(let i = 1; i < arr1.length; i++){
for(let j = 1; j < arr2.length; j++){
if(arr1){
console.log(i, j);
}
}
}
}
argu([1,2,3,4,5], [1,2,3,4,5])
**Your code so far**
function destroyer(arr, ...arg) {
/*let arg = Object.values(arguments).slice(1)
console.log(arguments)
for(let i = 0; i < arr.length; i++){
for(let j = 0; j < arg.length; j++){
if(arr[i] === arg[j]){
delete arr[i];
}
}
}
return arr.filter(x => x !== null)
*/
/*let arg = [x]
for(let i = 0; i < arr.length; i++){
for(let j = 0; j < arg.length; j++){
if(arr[i] === arg[j]){
delete arr[i];
}
}
}
return arr*/
for(let i = 0; i < arr.length; i++){
for(let j = 0; j < arg.length; j++){
if(arr[i] === arg[j]){
console.log(i, j);
}
}
return arr
}
}
console.log(
destroyer([1, 2, 3, 1, 2, 3], 2, 3));
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36
Challenge: Seek and Destroy
Link to the challenge: