Freecodecamp: infinite loop

Created on 18 Sep 2016  路  5Comments  路  Source: freeCodeCamp/freeCodeCamp

there's a test case that makes it possible for my algorithm to get into an infinite loop

Challenge Name

https://www.freecodecamp.com/challenges/drop-it

Issue Description

  • faulty code gets executed immediately upon navigation to challenge page, resulting in an an infinite loop.
  • Page freezes even after reloading or closing tab and navigating back to challenge web address.

Browser Information

Version: 39.0.2256.71 - Opera is up to date
Update stream: Stable
System: Windows 10 64-bit (WoW64)

Your Code

while(!func(arr[0])){arr.shift();}

Thank you.

Most helpful comment

check this out: https://github.com/freecodecamp/freecodecamp/wiki/FreeCodeCamp-Disable-Code-Autorun

try to add query string run=disabled to your URL

All 5 comments

@alevis There seems to be a problem in your code.

In the condition for the while loop, try using the correct condition (i.e. the second argument func instead of function)

Here's the code that'll solve the problem:

function dropElements(arr, func) {
  while(!func(arr[0])) {
    arr.shift();
  }
  return arr;
}

dropElements([1, 2, 3], function(n) {return n < 3; });

@ryzokuken thanks for catching the typo.
However whenever I navigate to http://www.freecodecamp,com/challenges/drop-it my code gets executed right away resulting in the infinite loop. If there was a way to stop code execution when I navigate to that page, that would solve it.

Try clearing the browser cache. I suppose your solution is stored locally

check this out: https://github.com/freecodecamp/freecodecamp/wiki/FreeCodeCamp-Disable-Code-Autorun

try to add query string run=disabled to your URL

@alevis check out the link that @ivantedja has pointed out above. If you get stuck or have questions with a challenge in the future, please first ask questions to the Help Room. Happy coding!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vaibsharma picture vaibsharma  路  3Comments

Tzahile picture Tzahile  路  3Comments

itsmikewest picture itsmikewest  路  3Comments

ar5had picture ar5had  路  3Comments

jurijuri picture jurijuri  路  3Comments