当前位置:网站首页>Record some small requirements in the form of cases
Record some small requirements in the form of cases
2022-07-28 21:36:00 【silence^】
1, With arr As a template ,arr1 It's the random data from the interface , To put arr1 According to arr Sort .
If arr1 There is , and arr Not found in , That is, the new interface , Just line up behind
var arr = ['t1', 't2', 't3', 't4', 't5', 't6', 't7']
var arr1 = ['t5', 'n2', 't3', 'n1','t1']
let temp = arr.filter(item => arr1.includes(item))
let temp1 = arr1.filter(item => !arr.includes(item))
let tempNew = temp.concat(temp1)
console.log(tempNew, 'tempNew') //['t1', 't3', 't5', 'n2', 'n1']0: "t1"1: "t3"2: "t5"3: "n2"4: "n1"length: 5[[Prototype]]: Array(0) 'tempNew'
2, From the key values in the array , Take out the value of the corresponding key , Sum up
var arr=[
{
a:1,b:443,c:12},
{
a:1,b:443,c:12},
{
a:1,b:443,c:12},
{
a:1,b:443,c:12},
{
a:1,b:443,c:12},
]
var arrtemp=[]
arr.map((item)=>{
arrtemp.push(item.b)
})
arrtemp.reduce((p,c)=>{
sum=p+c
return sum
})
console.log(sum)
边栏推荐
- Leetcode linked list problem -- 142. circular linked list II (learn the linked list by one question and one article)
- Layout the 6G track in advance! Ziguang zhanrui released the white paper "6G unbounded AI"
- 顶级“Redis 笔记”, 缓存雪崩 + 击穿 + 穿透 + 集群 + 分布式锁,NB 了
- Priced at 1.15 billion yuan, 1206 pieces of equipment were injected into the joint venture! Sk Hynix grabs the mainland wafer foundry market!
- 工业通讯领域的总线、协议、规范、接口、数据采集与控制系统
- What is the purpose of database read-write separation [easy to understand]
- 30. Learn highcharts label rotation histogram
- 华为发布首款电驱动系统DriveONE:充电10分钟续航200km
- Bus, protocol, specification, interface, data acquisition and control system in industrial communication field
- 1945. sum of digits after string conversion
猜你喜欢

Talk about row storage and column storage of database

Analysis of critical path

Bus, protocol, specification, interface, data acquisition and control system in industrial communication field

Achieve waterfall effect

Coding with these 16 naming rules can save you more than half of your comments!

Leetcode linked list question - interview question 02.07. linked list intersection (learn linked list by one question and one article)

Week 6 Linear Models for Classification (Part B)

如何度量软件架构

顶级“Redis 笔记”, 缓存雪崩 + 击穿 + 穿透 + 集群 + 分布式锁,NB 了

Kubedm builds kubernetes cluster
随机推荐
云安全核心技术
比UUID更快更安全NanoID到底是怎么实现的?(荣耀典藏版)
两个全局变量__dirname和__filename 、fs模块常用功能进一步介绍
Leetcode interview question 02.07. Linked list intersection [knowledge points: Double pointers, stack]
物联网技术栈之网关技术
The 35 required questions in MySQL interview are illustrated, which is too easy to understand
不用Swagger,那我用啥?
1945. sum of digits after string conversion
The general strike of three factories in St France may make the shortage of chips more serious!
The framing efficiency of setpreviewcallbackwithbuffer will become lower
针对下一代Chromebook,联发科推出新款芯片组MT8192和MT8195
Coolpad voluntarily terminated the patent infringement lawsuit against Xiaomi
聊一聊数据库的行存与列存
华为发布首款电驱动系统DriveONE:充电10分钟续航200km
ABB电磁流量计维修信号变送器维修41F/E4技术参数
CVPR 2022 | 网络中批处理归一化估计偏移的深入研究
Using El date picker to report errors in sub components
1162. Map analysis - non recursive method
小霸王被申请破产!公司成“老赖” ,法人被限制高消费
分页功能(板子)