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
Post a Comment