Write a java script program to print first 10 natural numbers by using for loop, while loop and do while loop?
Answers
Answered by
10
for (var i = 1; i <= 10; i++) {
console.log(i);
}
-------------------------------
var i = 1;
while (i <= 10) {
console.log(i);
i++
}
-------------------------------
var i = 1;
do {
console.log(i);
i++
} while (i <= 10)
Hope it helps...
Similar questions