📌  相关文章
📜  计算字符串中字符的出现次数 javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:03.484000             🧑  作者: Mango

代码示例6
function countInstancesOf(letter, sentence) {
  var count = 0;

  for (var i = 0; i < sentence.length; i++) {
    if (sentence.charAt(i) === letter) {
      count += 1;
    }
  }
  return count;
}