Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exercise: Count digits from string

  • Given a string of numbers, count how many times each digit appears.
let text = "1213 456 78843978523 3224 2421";
0: 0
1: 3
2: 6
3: 4
4: 4
5: 2
6: 1
7: 2
8: 3
9: 1