Skip to content

Instantly share code, notes, and snippets.

@RinatValiullov
Last active February 21, 2018 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RinatValiullov/e0c0aa19b7ad45e639d745dc40d17e97 to your computer and use it in GitHub Desktop.
Save RinatValiullov/e0c0aa19b7ad45e639d745dc40d17e97 to your computer and use it in GitHub Desktop.
Find biggest number with reduce
// e. g. let's take some array of numbers
let numbers = [11,55,2,98,115,32,116,48,154];

let biggest = numbers.reduce( (acc, curr) => {
    console.table({acc, curr});
    return curr > acc ? curr : acc;
});

// console.log(biggest); the biggest number will be 154;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment