The while loop in Javascript



The purpose of a while loop is to execute a statement or code block repeatedly as long as an expression is true. Once the expression becomes false, the loop terminates.

Example

For example −

let i = 0;
while (i < 5) {
   console.log("Hello");
   i = i + 1;
}

Output

This will give the output −

Hello
Hello
Hello
Hello
Hello
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know


Advertisements