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 in file

Write a function that receives a string as a parameter and returns an array of 10 numbers, the number of each digit in the file. At first you can assume the file contains a single row containing only digits: 234566. Then make the input file more complex

  • Having multiple rows and including digits and spaces.
  • Having multiple rows and including any character.

In each case we only need to count the number of each digit.