JavaScript Loops : While Loop

The While Loop is most basic loop in JavaScript. It is used to execute a specific block of code repeatedly as long as the given condition is true. In while loop the condition will checked first and If condition become true, execute a block of code executed. Syntax :
while (condition) {
  code to be executed
For example The below code will print the table of 2 :
<!DOCTYPE html>
  <title>While Loop</title>
  <p id="demo"></p>
    var x = 2, count = 1;
    var text = '';
    while(count <= 10) {
      text = text + x*count + '<br/>';
    document.getElementById("demo").innerHTML = text;
Output :

Next Topic :