find the number of times the letter e appears:
let str = "hello everyone";
< hr >
if so, the methods I can think of at present are:
- use the split method
let num = str.split ("e"). Length-1; num = > 4
) - use the match method (global search)
let reg = / str.match (reg) g; let num = str.match (reg) .length; num = > 4
is there any other way?