题解 | #计算某字母出现次数#

计算某字母出现次数

http://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1

const str = readline()
const chart = readline()
function getChartLen(str, chart) {
    if(!str || chart === null || chart === undefined){
        return 0
    }
    let strLen = str.length
    let len = 0
    str = str.toLowerCase()
    chart = chart.toLowerCase()
    for(let i = 0; i < strLen; i++) {
        if(str[i] === chart) {
            len++
        }
    }
    return len
}
console.log(getChartLen(str, chart))
全部评论

相关推荐

自学java狠狠赚一...:骗你点star的,港卵公司,记得把star收回去
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务