题解 | #统计字符#
统计字符
https://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void async function () { // Write your code here while(line = await readline()){ let charCount =0; let spaceCount =0; let numCount =0; let otherCount =0; for(let i of line) { if(/[A-Za-z]/.test(i)){ charCount++ } else if(/[0-9]/.test(i)){ numCount++ }else if(i === " ") { spaceCount++ } else { otherCount++ } } console.log(charCount + '\n'+ spaceCount + '\n' + numCount + '\n' + otherCount); } }()