Search code snippets, questions, articles...

Javascript Code for Sorting array and finding Largest No. in Array

let arr = [1,25,51,36,45,13,101]
const sorted = arr.sort((a, b) => a - b);
const Largest = arr.sort((a, b) => a - b)[arr.length - 1];
console.log(sorted)
console.log(Largest)
Was this helpful?
0 Comments
Programming Feeds
Learn something new everyday on Devsheet