📅  最后修改于: 2022-03-11 14:56:28.408000             🧑  作者: Mango
function count(str) {
var obj = {};
str.split(" ").forEach(function(el, i, arr) {
obj[el] = obj[el] ? ++obj[el] : 1;
});
return obj;
}
console.log(count("olly olly in come free"));