Tell us what’s happening:
NOt sure what is happening here and why I am getting most of the challenges wrong. For eg it returns true when 2>2.
Your code so far
function dropElements(arr, func) {
let newArr = [...arr];
let checkArr = [];
for(let i = 0;i < arr.length;i++){
checkArr.push(func(newArr[i]));
if(func(newArr[i])){
break;
}else{
newArr.shift();
}
}
console.log(checkArr);
console.log(newArr);
return newArr;
}
dropElements([1, 2, 3], function(n) {return n < 3; });
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36.
Challenge: Drop it
Link to the challenge: