当前位置:网站首页>JS to find duplicate elements in two arrays
JS to find duplicate elements in two arrays
2022-07-01 02:48:00 【Growing sunflower】
const a = [1, 2, 3, 4, 6, 5, 5]
const b = [5, 6, 7, 8, 5, 6, 9]
function repeatElement(a, b) {
let arr1 = []
for (let i = 0; i < a.length; i++) {
for (let j = 0; j < b.length; j++) {
if (a[i] == b[j] && arr1.indexOf(a[i]) == -1) {
arr1.push(a[i])
}
}
}
return arr1
}
console.log(repeatElement(a, b))
const a = [1, 2, 3, 4, 6, 5, 5]
const b = [5, 6, 7, 8, 5, 6, 9]
function repeatElement1(a, b) {
let arr = []
for (let i = 0; i < a.length; i++) {
if (b.indexOf(a[i]) !== -1 && arr.includes(a[i]) == false) {
arr.push(a[i])
}
}
return arr
}
console.log(repeatElement1(a, b))
边栏推荐
- SAP ALV汇总跟导出Excel 汇总数据不一致
- 小程序自定义顶部导航栏,uni-app微信小程序自定义顶部导航栏
- The latest wechat iPad protocol code obtains official account authorization, etc
- RestCloud ETL实践之无标识位实现增量数据同步
- 使用ipmitool配置X86服务器的BMC网络和用户信息
- 基于Pytorch完整的训练一个神经网络并进行验证
- js中的原型和原型链
- Borrowing constructor inheritance and composite inheritance
- Pulsar 主题压缩
- 5款主流智能音箱入门款测评:苹果小米华为天猫小度,谁的表现更胜一筹?
猜你喜欢
记一次服务部署失败问题排查
详解数据治理知识体系
Optimal Transport系列1
联想X86服务器重启管理控制器(XClarity Controller)或TSM的方法
Restcloud ETL practice to realize incremental data synchronization without identification bit
Introduction to kubernetes resource objects and common commands (II)
The mobile edge browser cannot open the third-party application
Youmeng (a good helper for real-time monitoring of software exceptions: crash) access tutorial (the easiest tutorial for Xiaobai with some foundation)
Restcloud ETL实践之数据行列转换
js中的原型和原型链
随机推荐
Evaluation of the entry-level models of 5 mainstream smart speakers: apple, Xiaomi, Huawei, tmall, Xiaodu, who is better?
How to realize the scene linkage of intelligent lock, lamp and intelligent curtain motor in zhiting?
AI edge computing platform - beaglebone AI 64 introduction
Focusing on green and low carbon, data center cooling has entered a new era of "intelligent cooling"
Visual effects, picture to cartoon function
STM32——一线协议之DS18B20温度采样
记一次服务部署失败问题排查
VirtualBox installation enhancements
Voici le programme de formation des talents de SHARE Creators!
单片机 MCU 固件打包脚本软件
基于OPENCV和图像减法的PCB缺陷检测
Restcloud ETL WebService data synchronization to local
鼠标悬停效果六
如果在小券商办理网上开户安全吗?我的资金会不会不安全?
鼠标悬停效果一
go: finding module for package
Cluster method synchronous execution framework suona
股票开户安全吗?上海股票开户步骤。
Pulsar的Proxy支持和SNI路由
MnasNet学习笔记