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

Generators tutorial in Advance JavaScript

Document Object Module DOM querySelector and querySelectorAll tutorial in JavaScript

Find Even and Odd Numbers with Loops tutorial in JavaScript