Read the question, write TypeScript on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read month 1–12; print days in a non-leap year.
Input. 1–12.
Output. 28/30/31.
Examples
Input
2
Output
28
Input
4
Output
30
Hint
- Array of day counts indexed by month.
Show correct code
Peek only after you have tried. You can still Check your own version.
const m = Number(readLine());
const days = [0,31,28,31,30,31,30,31,31,30,31,30,31];
console.log(days[m]);
main.tstsc · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.