Easiest way return largest numbers in arrays – Daily JavaScript #6

Hello đź‘‹,
It is very easy to do 🙂

function largestNumber(arr) {
// You can do this!
const largest = [];
for (let i = 0; i < arr.length; i++) {
largest.push(Math.max(…arr[i]));
}
return largest;
}

console.log(lar…


This content originally appeared on DEV Community and was authored by SnowBit

Hello đź‘‹,
It is very easy to do 🙂

function largestNumber(arr) {
    // You can do this!
    const largest = [];
    for (let i = 0; i < arr.length; i++) {
        largest.push(Math.max(...arr[i]));
    }
    return largest;
  }

  console.log(largestNumber([[105, 35, 63, 89], [130, 270, 128, 216], [312, 335, 357, 399], [1000, 1001, 857, 1]]))

This was a quick article, I hope it helped you

Thank you for reading, have a nice day!


This content originally appeared on DEV Community and was authored by SnowBit


Print Share Comment Cite Upload Translate Updates
APA

SnowBit | Sciencx (2022-01-12T09:20:06+00:00) Easiest way return largest numbers in arrays – Daily JavaScript #6. Retrieved from https://www.scien.cx/2022/01/12/easiest-way-return-largest-numbers-in-arrays-daily-javascript-6/

MLA
" » Easiest way return largest numbers in arrays – Daily JavaScript #6." SnowBit | Sciencx - Wednesday January 12, 2022, https://www.scien.cx/2022/01/12/easiest-way-return-largest-numbers-in-arrays-daily-javascript-6/
HARVARD
SnowBit | Sciencx Wednesday January 12, 2022 » Easiest way return largest numbers in arrays – Daily JavaScript #6., viewed ,<https://www.scien.cx/2022/01/12/easiest-way-return-largest-numbers-in-arrays-daily-javascript-6/>
VANCOUVER
SnowBit | Sciencx - » Easiest way return largest numbers in arrays – Daily JavaScript #6. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/01/12/easiest-way-return-largest-numbers-in-arrays-daily-javascript-6/
CHICAGO
" » Easiest way return largest numbers in arrays – Daily JavaScript #6." SnowBit | Sciencx - Accessed . https://www.scien.cx/2022/01/12/easiest-way-return-largest-numbers-in-arrays-daily-javascript-6/
IEEE
" » Easiest way return largest numbers in arrays – Daily JavaScript #6." SnowBit | Sciencx [Online]. Available: https://www.scien.cx/2022/01/12/easiest-way-return-largest-numbers-in-arrays-daily-javascript-6/. [Accessed: ]
rf:citation
» Easiest way return largest numbers in arrays – Daily JavaScript #6 | SnowBit | Sciencx | https://www.scien.cx/2022/01/12/easiest-way-return-largest-numbers-in-arrays-daily-javascript-6/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.