while Loops in JavaScript

 //while loop

let n = prompt("Enter the value of a : ");
n = Number.parseInt(n);
let i = 0;
while (i < n) {
    console.log(i);
    i++;
}

//do while loop
let n2 = prompt("Enter the value of b : ");
let i2 = 0;
do {
    console.log(i2);
    i2++;
} while (i2 < n2);

Comments

Popular posts from this blog

Symbols tutorial in Advance JavaScript

Async and Await Method tutorial in Advance JavaScript

String Methods in JavaScript