Tell us what’s happening:
I’m not sure why my code isn’t passing the last test
dropElements([1, 2, 3, 4], function(n) {return n > 5;})
Output should be an empty array but it’s returning [3,4] when I console.log it
All other tests pass
Any hints?
Your code so far
function dropElements(arr, func) {
let arrCopy = [...arr]
for (let i = 0; i < arrCopy.length; i++) {
if (func(arrCopy[0]) !== true) {
arrCopy.shift()
}
}
return arrCopy
}
console.log(dropElements([1, 2, 3, 4], function(n) {return n > 5;})) // []
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
.
Link to the challenge: