Tell us what’s happening:
It seems that myFunction2 returns the wrong values. It should take the element from onlyArr and check if it is present in args. If not, it should add that element to result array. Pls, help.
**Your code so far**
function destroyer(arr) {
var args = [...arguments];
var onlyArr = args.shift();
var result = [];
// Checking if args are in onlyArr
args.forEach(myFunction);
function myFunction(item) {
if (!(item in onlyArr)) {
result.push(item);
}
}
// Checking, if elements in onlyArr are in args
onlyArr.forEach(myFunction2);
function myFunction2(item) {
if (!(item in args)){
result.push(item);
}
}
console.log("Result:" + result);
return result;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3, 8);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Safari/537.36
Challenge: Seek and Destroy
Link to the challenge: