当前位置:网站首页>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))
边栏推荐
- Sampling Area Lights
- 如何在智汀中實現智能鎖與燈、智能窗簾電機場景聯動?
- servlet【初识】
- The mobile edge browser cannot open the third-party application
- 如果在小券商办理网上开户安全吗?我的资金会不会不安全?
- 鼠标悬停效果四
- Use ipmitool to configure BMC network and user information of X86 server
- Why are strings immutable in many programming languages? [repeated] - why are strings immutable in many programming languages? [duplicate]
- js中的图片预加载
- Focusing on green and low carbon, data center cooling has entered a new era of "intelligent cooling"
猜你喜欢

Dell服务器重启iDRAC方法

DenseNet网络论文学习笔记

Introduction to kubernetes resource objects and common commands (II)

Go import self built package

Restcloud ETL practice to realize incremental data synchronization without identification bit

Pycharm 打开远程目录 Remote Host
![[2022] Jiangxi postgraduate mathematical modeling scheme and code](/img/f4/86b0dc2bd49c3a54c1e0538b31d458.png)
[2022] Jiangxi postgraduate mathematical modeling scheme and code

详解数据治理知识体系

Pychar open remote directory remote host

Machine learning 9-universal approximator radial basis function neural network, examining PDA and SVM from a new perspective
随机推荐
Ipmitool download address and possible problems during compilation and installation
import tensorflow.contrib.slim as slim报错
5款主流智能音箱入门款测评:苹果小米华为天猫小度,谁的表现更胜一筹?
Mouse over effect V
鼠标悬停效果三
Sampling Area Lights
Analysis and solution of anr problems
[multi source BFS] 934 Shortest Bridge
Pulsar的Proxy支持和SNI路由
记一次服务部署失败问题排查
Pychar open remote directory remote host
Pulsar geo replication/ disaster recovery / regional replication
Nacos configuration center tutorial
详解数据治理知识体系
集群方法同步执行框架 Suona
robots.txt限制搜索引擎收录
Optimal transport Series 1
js中的原型和原型链
园区运营效率提升,小程序容器技术加速应用平台化管理
Poj-3486-computers[dynamic planning]