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

计算某字符出现次数

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

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let rlArr = []
function callback([str, char]) {
    str = str.toUpperCase()
    char = char.toUpperCase()

    const count = str.split(char).length - 1
    console.log(count)
}

rl.on('line', function (line) {
    rlArr.push(line)
    if (rlArr.length === 2) {
        callback([rlArr[0], rlArr[1]])
    }
});


全部评论

相关推荐

点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务