- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Return Largest Numbers in Arrays passed using reduce method?
To get largest numbers passed using reduce(), use the Math.max() function. Following is the code −
const getBiggestNumberFromArraysPassed = allArrays => allArrays.reduce( (maxValue, maxCurrent) => maxValue.push(Math.max(...maxCurrent)),maxValue),[]); console.log(getBiggestNumberFromArraysPassed([[45,78,3,1],[50,34,90,89],[32,10,90,99]]));
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo94.js
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo94.js [ 78, 90, 99 ]
Advertisements
To Continue Learning Please Login
Login with Google