当前位置:网站首页>There are a group of students in the class who have got the test results in Chinese and mathematics. Please select the students whose total score is the first
There are a group of students in the class who have got the test results in Chinese and mathematics. Please select the students whose total score is the first
2022-07-26 03:10:00 【Two faces confused】
subject : There are a group of students in the class whose exam results come out , I took Chinese and Mathematics , Please select the students whose total score is the first
requirement :
1. Data types are defined by themselves , It can be screened out
2. With the same total score , It's tied for the first place They're all screened out
const arr = [
{id: 1, name: ' Xiao Zhang ', language: '98', math: '100'},
{id: 2, name: ' petty thief ', language: '90', math: '98'},
{id: 3, name: ' Zhang San ', language: '98', math: '100'},
{id: 4, name: ' Li Si ', language: '90', math: '97.5'},
{id: 5, name: ' Wang Wu ', language: '99', math: '99'},
{id: 6, name: ' Zhao Liu ', language: '78', math: '88'}
];
let topArr = [];
for (let i = 1; i < arr.length; i++) {
if ((arr[i].language + arr[i].math) > (arr[i - 1].language + arr[i - 1].math)) {
topArr.push(arr[i])
} else if ((arr[i].language + arr[i].math) == (arr[i - 1].language + arr[i - 1].math)) {
topArr.push(arr[i], arr[i - 1])
} else {
topArr.push(arr[i - 1])
}
}
console.log(new Set(topArr));// adopt new Set() Deduplication

link : Array de duplication method
边栏推荐
- Neo4j 导入csv数据报错:Neo4j load csv error : Couldn‘t load the external resource
- 【尤里复裂人】带你轻松理解——深拷贝和浅拷贝
- [sql] case expression
- Opening method of win11 microphone permission
- Cloud native guide what is cloud native infrastructure
- js中数组排序的方法有哪些
- VR panoramic shooting and production of business center helps businesses effectively attract people
- 软件测试岗:阿里三面,幸好做足了准备,已拿offer
- Continuous delivery and Devops are good friends
- Three years of software testing experience, salary has been stuck at 10K, how to improve and develop automated testing?
猜你喜欢

经典面试问题——OOP语言的三大特征
![[noip2001 popularization group] packing problem](/img/b7/1310b3e68d0ee016465fc069315af6.png)
[noip2001 popularization group] packing problem

How to install with USB flash disk?

如何根据登录测试的需求设计测试用例?

JVM内存模型解析

Managing databases in a hybrid cloud: eight key considerations

Arthas' dynamic load class (retransform)

Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 1)

JVM memory model parsing

FPGA_ Initial use process of vivado software_ Ultra detailed
随机推荐
[SQL] CASE表达式
Unity quickly builds urban scenes
移位距离和假设的应用
Self-supervised learning method to solve the inverse problem of Fokker-Planck Equation
(9) Attribute introspection
cmd cpm 命令汇总
STM - exti external interrupt learning notes
[SQL] 自连接的用法
canvas——绘制图片——动图制作
Keyboardtraffic, a tool developed by myself to solve CTF USB keyboard traffic
Arthas view the source code of the loaded class (JAD)
复制列表时踩过的坑:浅拷贝与深拷贝
Difference between soft link and hard link
QT signal transmission between multi-level objects signal transmission between multi-level nested class objects
Programming example of STM32 state machine -- fully automatic washing machine (Part 1)
堆内存与栈内存的区别?
Arthas' dynamic load class (retransform)
如何正确计算 Kubernetes 容器 CPU 使用率
Software testing post: Ali has three sides. Fortunately, he has made full preparations and has been offered
[noip2001 popularization group] packing problem