var answer1=arguments[0];
var value1=arguments[1];
var value2=arguments[2];
var finalAnswer=[];
console.log(answer1);
console.log(value1);
console.log(value2);
for (var i=0;i<=answer1.length-1;i++ ){
if (answer1[i]===value2 || answer1[i]===value1){
finalAnswer= answer1.splice(i,1);
finalAnswer.pop();
}
}
console.log(answer1);
console.log(finalAnswer);
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Hi I tried this Seek and Destroy Challenge but my if statement is not working properly. Its not checking for the or option. Its not checking for the comparison of “answer1[i]===value2” option at all.
Any suggestions why?
I know this doesn’t answer your question, but I’ve also had difficulty making || or && work inside if statements, so I’ve just stopped trying. An alternative would be to just do something like:
if (first condition){
code you want}
else if (second condition){
same code as above}
I’m pretty sure the “else if” would prevent the code from running twice if both conditions were true, and otherwise the truth values would work out the same. You can do a fake && by just nesting two if statements as well.
So, that would at least get you by for now, and then maybe later someone who knows what they’re talking about could explain why things are that way.