TypeScript: Greet with types

Read a name and an age with typed variables and print a greeting that does arithmetic with the age.

What to build

A program that greets a person and says how old they will be in 10 years.

Requirements

  • Read the name into a string and the age into a number.
  • Print exactly: Hello, NAME! You are AGE. In 10 years you will be AGE10. where AGE10 is the age plus 10.

Input

Line 1: a name. Line 2: a whole number, the age.

Output

One line, the greeting.

Constraints

0 ≤ age ≤ 150.

Example

Input:

Ada
36

Output:

Hello, Ada! You are 36. In 10 years you will be 46.

Why it works

prompt() gives text, so the age must be converted with Number() before adding 10: with + on two strings, "36" + 10 would give "3610", and the number type on the variable makes TypeScript insist on the conversion.

Examples

Example 1 · Input
Ada
36
Expected output
Hello, Ada! You are 36. In 10 years you will be 46.
Example 2 · Input
Rahim
0
Expected output
Hello, Rahim! You are 0. In 10 years you will be 10.

Hints

Hint 1

Number() turns the text of a line into a number.

Hint 2

Join the parts of the sentence with + or a template string.

Solution

Show one correct solution (try it yourself first)
const read = (): string => prompt() ?? "";
const name: string = read();
const age: number = Number(read());
console.log("Hello, " + name + "! You are " + age + ". In 10 years you will be " + (age + 10) + ".");

Lesson: Why TypeScript →