/Exercises
Find Largest Number
0 / 19 solved
easyArraysMath

Find Largest Number

Given an array of numbers, return the largest number in the array.

Examples
Input: [3, 1, 7, 2, 9]
Output: 9
Input: [-5, -1, -3]
Output: -1
-1 is the largest even with all negatives.
Input: [42]
Output: 42
Single element is always the largest.
Constraints
  • Array will have at least 1 element.
  • Elements can be negative, zero, or positive.
solution.js
syntaxautocompletefoldsearch
Ctrl+Enter run  · Ctrl+Z undo  · Ctrl+F search  · Tab indent  · Ctrl+/ comment
Press Run to test your solution