题解 | #计算某字母出现次数#
计算某字母出现次数
http://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
//先把要查找的字符串以及被查找的字符串都变成小写 let str = readline().toLowerCase(); let findstr = readline().toLowerCase(); function getCodeNum(str,findstr){ let num = 0,strArr = [...str]; for (let i of strArr) { if(i === findstr){ num ++; } } return num; } console.log(getCodeNum(str,findstr));