题解 | #计算某字符出现次数# 攒人品
计算某字符出现次数
https://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
//输入输出参考一下文章 //https://blog.csdn.net/weixin_44774630/article/details/123404107?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-0-123404107-blog-116506148.235^v38^pc_relevant_sort_base2&spm=1001.2101.3001.4242.1&utm_relevant_index=1 var readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const lines=[] rl.on("line",function(line){ lines.push(line) }) rl.on("close",()=>{ let str=lines[0].toLowerCase() let char=lines[1].toLowerCase() let ans=0 for(let i=0;i<str.length;i++){ if(str[i]===char){ ans++ } } console.log(ans) })#算法记录#