Skip to main content

Command Palette

Search for a command to run...

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

Published
β€’1 min read
Easiest way return largest numbers in arrays - Daily JavaScript #6
D

I am 17 years old and a young passionate and self-taught frontend web developer and have an intention to become a successful developer. I usually write about JavaScript and Web Development and share some tips in the articles.

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!

More from this blog

D

Dhairya Shah

119 posts