当前位置:网站首页>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))
边栏推荐
- Desai wisdom number - other charts (parallel coordinate chart): employment of fresh majors in 2021
- Restcloud ETl数据通过时间戳实现增量数据同步
- nacos配置中心使用教程
- In the industrial Internet, "small" programs have "big" effects
- UE4 rendering pipeline learning notes
- Viewing JVM parameters
- A small document of JS method Encyclopedia
- js防抖和节流
- Pulsar geo replication/ disaster recovery / regional replication
- 如何在智汀中實現智能鎖與燈、智能窗簾電機場景聯動?
猜你喜欢

在unity中使用jieba分词的方法

Go import self built package

详解数据治理知识体系

Find the length of the common part of two line segments

Share Creators萌芽人才培养计划来了!

Small program cloud development -- wechat official account article collection

Focusing on green and low carbon, data center cooling has entered a new era of "intelligent cooling"

Pycharm 打开远程目录 Remote Host

VirtualBox installation enhancements

The operation efficiency of the park is improved, and the application platform management of applet container technology is accelerated
随机推荐
ssh配置免密登录时报错:/usr/bin/ssh-copy-id: ERROR: No identities found 解决方法
在国内如何买港股的股?用什么平台安全一些?
集群方法同步执行框架 Suona
How to realize the scene linkage of intelligent lock, lamp and intelligent curtain motor in zhiting?
The latest wechat iPad protocol code obtains official account authorization, etc
查看 jvm 参数
Comment réaliser la liaison entre la serrure intelligente et la lampe, la scène du moteur de rideau intelligent dans le timing intelligent?
联想X86服务器重启管理控制器(XClarity Controller)或TSM的方法
LeetCode_栈_困难_227.基本计算器(不含乘除)
Pulsar theme compression
Here comes the share creators budding talent training program!
记一次服务部署失败问题排查
Sampling Area Lights
Dell服务器重启iDRAC方法
Pychar open remote directory remote host
Résumé des styles de développement d'applets Wechat
Optimal transport Series 1
5款主流智能音箱入门款测评:苹果小米华为天猫小度,谁的表现更胜一筹?
【微信小程序開發】樣式匯總
js中的图片预加载