Tell us what’s happening:
Hi everyone,
I guess this code is not the best option, but I was wandering if it’s possible to solve this problem via using this method. It is not working for some reason and I want to know why - if possible, please explain this to me (if it’s workable at all).
Thanks in advance!
Your code so far
function destroyer(arr) {
// Remove all the values
for (var i = 0; i < arr.length;i++){
var firstElement = arr[0];
for(var j =1; j < arr.length;j++){
var otherElements = arr[j][0];
}
for(var k = 0; k < firstElement.length;k++){
var newArr = [];
if (firstElement[k]!==otherElements){
newArr.push(firstElement);
}
}
}
return newArr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/seek-and-destroy