TypeScript bootcamp · Lab 11

Countdown

easyFor8 minLesson: For

Read the question, write TypeScript on the right, then Run or Check.

QuestionHint and solution stay closed until you open them

Read n and print n, n-1, …, 1 each on its own line.

Input. One integer n ≥ 1.

Output. n lines counting down.

Examples

Example 1
Input
3
Output
3
2
1
Hint
  1. for (let i = n; i >= 1; i--) console.log(i);
Show correct code

Peek only after you have tried. You can still Check your own version.

const n: number = Number(readLine());
for (let i = n; i >= 1; i--) console.log(i);
main.tstsc · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.