TypeScript bootcamp · Lab 02

Sum two numbers

easyTypes8 minLesson: Data Types

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

QuestionHint and solution stay closed until you open them

readLine() reads a stdin line. Read two numbers and log their sum. Annotate the variables as number.

Examples

Example 1
Input
3
5
Output
8
Example 2
Input
10
-4
Output
6
Hint
  1. const a: number = Number(readLine());
Show correct code

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

const a: number = Number(readLine());
const b: number = Number(readLine());
console.log(a + b);
main.tstsc · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.