Read the question, write TypeScript on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read a line; print how many digit characters it contains.
Input. One line.
Output. Count.
Examples
Input
ab12c3
Output
3
Input
hello
Output
0
Hint
- /[0-9]/g match length
Show correct code
Peek only after you have tried. You can still Check your own version.
const line = readLine();
console.log((line.match(/[0-9]/g) || []).length);
main.tstsc · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.