TypeScript bootcamp · Lab 38

Letter grade

easyIf Else10 minLesson: If Else

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

QuestionHint and solution stay closed until you open them

Score → A/B/C/D/F bands.

Examples

Example 1
Input
95
Output
A
Example 2
Input
72
Output
C
Hint
  1. if / else if chain
Show correct code

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

const s: number = Number(readLine());
let g = 'F';
if (s >= 90) g = 'A';
else if (s >= 80) g = 'B';
else if (s >= 70) g = 'C';
else if (s >= 60) g = 'D';
console.log(g);
main.tstsc · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.