当前位置:网站首页>js查找字符串中出现了三次的字符
js查找字符串中出现了三次的字符
2022-04-23 05:56: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://blog.csdn.net/vfjcgg/article/details/122943014
边栏推荐
猜你喜欢

微信小程序之 js 时间戳/1000 转换 秒,六个小时后,一天后,本周五 选项计算时间

VHDL finite state machine (FSM) code example

Makefile foundation, common functions and general makefile

js根据名字将数组对象中名字相同的项组成一个相同的数组

uniapp 自定义搜索框适配小程序对齐胶囊

ASP.NET CORE3.1 Identity注册用户后登录失败的解决方案

.Net Core3.1 使用 RazorEngine.NetCore 制作实体生成器 (MVC网页版)

Error in created hook: “ReferenceError: “Promise”未定义“

解析psd文件,并映射成组件

.Net Core 下使用 Quartz —— 【1】快速开始
随机推荐
Overview of node file system and buffer
C# webpai 路由详解
自用学习笔记-连接式与非连接式访问数据库
解析psd文件,并映射成组件
js面试题:fn.call.call.call.call(fn2) 解析
Informatics one book pass - small ball
Understanding of SSH public key and private key
Use of shell scripts & and 𞓜
出入库与库存系统的模型问题
Interprocess communication - mutex
Krypton binary
NodeJS 模块之间的使用
ASP.NET CORE3.1 Identity注册用户后登录失败的解决方案
Multibyte and Unicode in VS
Redux概述
Redux概述
往String原型上封装一个时间戳转日期的方法
Wildcards and special symbols for shell scripts
2022ldu winter vacation training - program patch
SignalR实现从服务端主动发送数据到客户端