How will I make a script that will count the number of a specific letter in a Lorem text? Like if I type d in the chat box it will display a number in the div of how many dās there are in the text.
Asked
Active
Viewed 33 times
-1
-
Loop through each character, and count them. ā Ibu Jan 08 '19 at 23:22
-
This is what you want: https://jsfiddle.net/twinbird24/pn4h2zux/ ā Attila Jan 08 '19 at 23:58
1 Answers
0
You can go through each character in the string, and use an associative array to keep a running tally. Then output the key and value of that associative array.

NiteRain
- 663
- 8
- 14