题解 | #字符串字符统计#
字符串字符统计
http://www.nowcoder.com/practice/777d0cd160de485cae0b1fd1dd973b44
for of 迭代可迭代对象
function count(str) { const m = {} for(let k of str){ if(k === ' ') continue if(k in m){ m[k]++ } else { m[k] = 1 } } return m }
字符串字符统计
http://www.nowcoder.com/practice/777d0cd160de485cae0b1fd1dd973b44
for of 迭代可迭代对象
function count(str) { const m = {} for(let k of str){ if(k === ' ') continue if(k in m){ m[k]++ } else { m[k] = 1 } } return m }
相关推荐