My console is freezing and will not update. Any ideas why?

I’m working on the JS and Algorithms course and pasting some of the solutions to the last section in VS Code. I’m studying the solutions so I can understand them. For some reason, ONLY that js file is freezing up. I’m using Windows 10 and the task manager is showing Google Chrome tasks as very high.

Do algorithms use a lot of RAM or something. Anything I can do to fix this problem?

It depends on the algorithm and the size of the data set.

My guess is that you either have an infinite loop or the combination of your choice of how to solve the problem and the size of the data set is causing your computer to run very hard.

Simplify things. Try a smaller data set. Put some “limiters”, like a count variable that once it reaches 1,000,000 you exit the function no matter what. Work the problem.

If you show your code we might be able to help you more.

It’s one of the first few challenges here: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/#intermediate-algorithm-scripting

They are all small arrays so I don’t think that is it. I’ll try to figure out which challenge it is and just do that one in CodePen.

The 12th challenge in that section has a solution that I kind of understood and it has a while loop. That’s probably what is creating an infinite loop, but I’d have to read up on those to see how you fix that.

Well, nearly any loop can be infinite, depending on what you do. But yeah, the while loops are easy to screw up, if you’re not careful. If I’m having difficulty, sometimes I’ll put a counter in there so I can limit how many times it runs.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.