In this section, we'll be exploring the art of getting lost in an infinite loop.
Here's a simple example:
while (true) {
console.log("We're stuck in an infinite loop!");
}
But what if we want to make it more interesting?
Introducing... the Loop-de-Loop!
A variation of the classic loop, but with a few more twists and turns.
while (true) {
console.log("Stuck in a loop! (But it's not that bad, really.)");
if (Math.random() < 0.5) {
console.log("Whoa, we took a detour!");
} else {
console.log("Nope, back to the start.");
}
}