TypeScript bootcamp · Lab 05

Times table

easyFor10 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. Log n x 1 = … through n x 10 = …

Examples

Example 1
Input
3
Output
3 x 1 = 3
3 x 2 = 6
3 x 3 = 9
3 x 4 = 12
3 x 5 = 15
3 x 6 = 18
3 x 7 = 21
3 x 8 = 24
3 x 9 = 27
3 x 10 = 30
Hint
  1. for (let i = 1; i <= 10; 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 = 1; i <= 10; i++) {
  console.log(`${n} x ${i} = ${n * i}`);
}
main.tstsc · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.