当前位置:网站首页>JS to find the character that appears three times in the string
JS to find the character that appears three times in the string
2022-04-23 17:03:00 【Eli-sun】
let str = 'abvfFiioipuipplljlnnyfsaa'
let arr = str.split('')
console.log('111',arr);
arr = arr.sort()
console.log('222',arr);
let temp = []
for(var i=0;i<arr.length;i++){
let sum = 0
for(var j=0;j<arr.length;j++){
if(arr[i] === arr[j]){
sum+=1
}
}
if(sum === 3){
temp.push(arr[i])
temp = [...new Set(temp)]
}
}
console.log('333',temp); // ['a', 'l', 'p']
版权声明
本文为[Eli-sun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230554289577.html
边栏推荐
- STM32__ 03 - beginner timer
- Milvus 2.0 質量保障系統詳解
- 批量制造测试数据的思路,附源码
- Detailed explanation of Niuke - Gloves
- Calculate pie chart percentage
- 【题解】[SHOI2012] 随机树
- 面试百分百问到的进程,你究竟了解多少
- Knowledge points and examples of [seven input / output systems]
- Blue Bridge Cup provincial road 06 -- the second game of the 12th provincial competition
- SQL database
猜你喜欢
CentOS MySQL multi instance deployment
The new MySQL table has a self increasing ID of 20 bits. The reason is
How to build tiktok user trust and drive fan growth
扫码登录的原理你真的了解吗?
Zhongang Mining: Fluorite Flotation Process
org. apache. parquet. schema. InvalidSchemaException: A group type can not be empty. Parquet does not su
Milvus 2.0 质量保障系统详解
Pycham connects to the remote server and realizes remote debugging
Nacos + aspnetcore + Ocelot actual combat code
How to choose the wireless gooseneck anchor microphone and handheld microphone scheme
随机推荐
【生活中的逻辑谬误】稻草人谬误和无力反驳不算证明
【题解】[SHOI2012] 随机树
Calculate pie chart percentage
扫码登录的原理你真的了解吗?
蓝桥杯省一之路06——第十二届省赛真题第二场
Handwritten event publish subscribe framework
Shell脚本——Shell编程规范及变量
True math problems in 1959 college entrance examination
Camtasia2022软件新增功能介绍
VsCode-Go
Knowledge points and examples of [seven input / output systems]
Decimal format decimal / datetime conversion processing
Smart doc + Torna generate interface document
Summary of common websites
Milvus 2.0 質量保障系統詳解
【PIMF】OpenHarmony啃论文俱乐部—在ACM Survey闲逛是什么体验
Installing labellmg tutorial in Windows
自定义my_strcpy与库strcpy【模拟实现字符串相关函数】
PostgreSQL column storage and row storage
How to implement distributed locks with redis?