题解 | #计算某字符出现次数#
计算某字符出现次数
http://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
function repeatNum () {
const str = readline()
const rep = readline()
const strlow = str.toLowerCase();
const replow = rep.toLowerCase();
let equal = 0;
// const strArr = strlow.split('');
for (s of strlow) {
if (s === replow) {
equal++
}
}
return equal
}
console.log(repeatNum('c', 'f'))
获取第一行,第二行数据的方法用readline()