0

I have this code which does the count of the occurrences of a character in a string:

window.pqp = dddddd.trim(); // THE WORD FROM THE DATABASE

window.tbInput = $('input[name="tbInput"]').val(); // THE INPUT BOX THAT RECEIVES A VALUE THAT IS INSERTED BY THE USER.

This is the code to count the occurence:

window.count = (pqp.match(tbInput) || []).length;

The word that comes is “testal” and the user types in the input-box the letter “t”, it should count 2 but instead it counts 1.

Can anyone help me out with this one?

Lypyrhythm
  • 324
  • 2
  • 13

0 Answers0