Tell us what’s happening:
Hello, I’m still coming up with a plan for addressing this challenge and just trying to write up my basic approach. I looked at the hint and saw that three approaches were suggested. slice() and shift() I understand because shift would be used to remove the first element and the condition for that could be func !== true and slice() and can’t explain so well, but I can speculate that it could be used to create a new arr without any of the elements which do not meet the condition of func and return that as arr (understanding probably a bit flawed there…)
However, I don’t understand how arguments object could be of ANY use. Isn’t arguments object for revealing elements that are not visible and don’t you have all elements available? Why do you need to use arguments? It seems like, at best, ornament and nothing more. Slice and shift seem the most useful and functional.
Where am I wrong in my understanding?
Your code so far
//
function dropElements(arr, func) {
while(func !== true){
arr.shift();
}
console.log(arr)
return arr;
}
dropElements([1, 2, 3, 4], function(n) {return n > 5; });
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/drop-it/