Quick actions

cmd+k|ctrl+k

Navigation

Languages

while loop

Snippet info

Language

JavaScript

Visibility

public

Author

pinstudio

Created

2026-02-11T06:58:05.339738Z

Updated

2026-02-11T07:06:51.337167Z

x =1;
while (x < 10) {
    console.log(++x);
    if (x == 5) {
        break; // leave the while loop
    }
    if (x == 3) {
        continue; //go to top (while)
    }
console.log("while loop run,", x);}

console.log("separate")

x =1;
while (x < 10) {
    console.log(++x);
    if (x == 5) {
        break; // leave the while loop
    }
    if (x == 3) {
        continue; //go to top (while)
    }}
console.log("while loop run,", x);
INFO