DEV Community

Siddharth Kanojiya
Siddharth Kanojiya

Posted on

While Loops in JavaScript | JavaScript #8

// The while loop
// The syntax of the while loop look like this :
// while (condition){
// ||code to excuted
// }
// Note : if the condition never become false the while loop will never end this might crash the runtime
// To explain

// let n = prompt("Enter the value of n")
// n = Number.parseInt(n)

// let i = 0;
// while(i<n){
// console.log(n)
// i++;
// }

// do while loop

let n = prompt("Enter the value of n")
n = Number.parseInt(n)

let i = 0;
do{
console.log(i)
i++;
}while (i < n )

Top comments (0)