Read the question, write TypeScript on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Count whitespace-separated words on one line.
Examples
Input
hello world
Output
2
Hint
- trim split filter
Show correct code
Peek only after you have tried. You can still Check your own version.
const line: string = readLine().trim();
console.log(line === '' ? 0 : line.split(/\s+/).length);
main.tstsc · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.