Stuck on a challenge

Stuck on a challenge


When I log on to freecodecamp, it sends me to the challenge called ‘Drop It’. But that page has always been frozen for some reason. It hasn’t been working for weeks. I’ve been using Safari instead of Chrome to try and complete the rest of my challenges, but how do I fix that on Chrome? Is it the while loop?


Your solution’s logic is not correct. When your code runs the following test:

dropElements([1, 2, 3, 4], function(n) {return n > 5;});

an infinite loop is created, since none of the array elements cause the function to return false. Because the function in this test always returns false and you put a ! in front of the function call, the while loop condition yields true each time and continues to try and shift elements out of the array. Even after all the elements (1, 2, 3, 4) are no longer present, your arr[0] becomes undefined and since undefined is not greater than 2, the callback function still returns false.

The infinite loop makes the browser “freeze”.

If you load the challenge url and put ?run=disabled at the end of the url, it will allow you to open the page without the tests automatically running. Then, you can make adjustments to your code and removed the ?run=disabled and be able to run the tests again.