I thought 'While'' loops were infinite until the condition was true


var understand = true;

while( Math.random() < 0.5 ){
console.log("I'm learning while loops!");
understand = false;

When I submit this code, it either give me an error or says "Way to go!" displaying the console text to the right. My question is, shouldn't it keep running the loop until the condition is under 0.5, meaning that in theory it always passes me? If not, why not?


Not until the condition is true but while the condition is true (until it gets false).
But either way your condition is based on a random event so you either run the loop Math.random() is smaller than 0.5 or you don't Math.random() > 0.5, the variable understand isn't used in this process. Probably the exercise expects to read the string so you can only pass when the loop runs at least once, do you?

What about this?
You pick a value for understand that is below 0.5.
Use understand < 0.5 as condition
and inside your while loop compute the new value of understand by `understand = Math.random()`.

This way your loop would run at least once you have a meaningful while loop and you can pass the exercise.