直接上代码
let str = 'apple';
let obj = {};
let number = 0;
let activeIndex = '';
[...str].map(key => {
key in obj ? obj[key]++ : (obj[key] = 1);
obj[key] > number ? (activeIndex = key) : '';
number = obj[key];
});
console.log(activeIndex); // p
#
文章的内容/灵感都从下方内容中借鉴
【持续维护/更新 500+前端面试题/笔记】https://github.com/noxussj/Interview-Questions/issues
【大数据可视化图表插件】https://www.npmjs.com/package/ns-echarts
【利用 THREE.JS 实现 3D 城市建模(珠海市)】https://3d.noxussj.top/