当前位置:网站首页>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
边栏推荐
- The new MySQL table has a self increasing ID of 20 bits. The reason is
- ◰GL-着色器处理程序封装
- Dancenn: overview of byte self-developed 100 billion scale file metadata storage system
- STM32__ 03 - beginner timer
- 详解牛客----手套
- 手写事件发布订阅框架
- Error in v-on handler: "typeerror: cannot read property 'resetfields' of undefined"
- 博士申请 | 厦门大学信息学院郭诗辉老师团队招收全奖博士/博后/实习生
- 线性代数感悟之2
- SQL: How to parse Microsoft Transact-SQL Statements in C# and to match the column aliases of a view
猜你喜欢
自定义my_strcpy与库strcpy【模拟实现字符串相关函数】
How much do you know about the process of the interview
Nodejs reads the local JSON file through require. Unexpected token / in JSON at position appears
Node access to Alipay open platform sandbox to achieve payment function
Mock test
Nodejs installation and environment configuration
Mock test using postman
Change the password after installing MySQL in Linux
How to choose the wireless gooseneck anchor microphone and handheld microphone scheme
Bytevcharts visual chart library, I have everything you want
随机推荐
How does flash cache data in memory?
Idea of batch manufacturing test data, with source code
Shell script -- shell programming specification and variables
Milvus 2.0 質量保障系統詳解
Aiot industrial technology panoramic structure - Digital Architecture Design (8)
详解牛客----手套
The new MySQL table has a self increasing ID of 20 bits. The reason is
手写事件发布订阅框架
About stream flow, write it down briefly------
VLAN高级技术,VLAN聚合,超级Super VLAN ,Sub VLAN
Smart doc + Torna generate interface document
PHP高效读大文件处理数据
groutine
1-2 characteristics of nodejs
Promise (I)
Shell脚本——Shell编程规范及变量
Use between nodejs modules
Sub database and sub table & shardingsphere
深入了解3D模型相关知识(建模、材质贴图、UV、法线),置换贴图、凹凸贴图与法线贴图的区别
_ Mold_ Board_