////请输入下列水果共出现的次数
var arr = ["apple","orange","apple","orange","pear","orange"];
function getCount(){
arr.reduce(function(){},{})

}
function getWordCnt(){
return arr.reduce(function(prev,next){
prev[next] = (prev[next] + 1) || 1;
return prev;
},{});
}
var arr = ["apple","orange","apple","orange","pear","orange"];

 

console.log(getWordCnt());

 

es6元素出现的次数

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案