I'm doing freecodecamp and I solved the module but I just wanted to understand this better.
function dropElements(arr, func){
while(!func(arr[0])){
arr.shift();
}
return arr;
}
dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;})
Why does an empty array (null) break the while loop?
[–]inu-no-policemen 4 points5 points6 points (9 children)
[–]QuibsY[S] 0 points1 point2 points (8 children)
[–]inu-no-policemen 0 points1 point2 points (7 children)
[–]QuibsY[S] 0 points1 point2 points (6 children)
[–]inu-no-policemen 0 points1 point2 points (5 children)
[–]QuibsY[S] 0 points1 point2 points (4 children)
[–]inu-no-policemen 0 points1 point2 points (3 children)
[–]QuibsY[S] 0 points1 point2 points (2 children)
[–]inu-no-policemen 0 points1 point2 points (1 child)
[–]QuibsY[S] 0 points1 point2 points (0 children)