Skip to content
Advertisement

How to count the number of letters in a word?

I’m trying to create a program where if you input a word, it will print out each letter of the word and how many times the letter appears in that word.

Eg; when I input “aaaarggh”, the output should be “a 4 r 1 g 2 h 1”.

JavaScript

So far it just prints out each letter and position in the word. Any help appreciated, thank you!

(no using dict method)

Advertisement

Answer

JavaScript

output

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement