Print one to nine


Posted by Christy on 2022-04-19

Description: Print one to nine with for loop, while loop and do…while loop

// The input would be below:

1
2
3
4
5
6
7
8
9
// for loop

for (let i = 1; i <= 9; i++) {
  console.log(i);
}
// while loop

let i = 1;
while (i <= 9) {
  console.log(i);
  i++;
}
// do...while loop

let i = 1;
do {
  console.log(i);
  i++;
} while (i <= 9);









Related Posts

Gomoku with React 用 React 做一個五子棋小遊戲

Gomoku with React 用 React 做一個五子棋小遊戲

一些不太好記卻很好用的 CSS 屬性

一些不太好記卻很好用的 CSS 屬性

解決 JS 中 input file 無法重選相同文件的問題

解決 JS 中 input file 無法重選相同文件的問題


Comments