Hello, Gbemiga,
I’m not affiliated with Mozilla; I’m a fellow learner, like you. I played around with a similar loop construct on W3Schools.com, and I can at least largely answer your question.
Assuming you start the loop with i = 500, the first iteration checks to see if 500 is prime. Since it isn’t, the continue statement gets run. Execution then skips the rest of the loop, including the decrement, and returns to the while statement. The problem is, i is still 500 at this point. The same things happen again, and you end up with an infinite loop because i is never decremented. I don’t see, then, how you got your output. The else clause would have to be run to produce it, and I don’t see how it ever could be.
Try moving the decrement up before the const res = isPrime(i) statement. A couple of other changes would have to be made to preserve the intended behavior. I’ll leave it for you to figure out what they are.
And by the way, you’re missing the ending semicolon on all your statements except the continue. That didn’t seem to make any difference, however, when I tried it at W3Schools.