finding the largest number in an array
I have some code im having trouble with if someone could give me an idea or an answer id be greatly in your debt.
function getLargestNumber(numbers) {
}
/* Do not modify code below this line */
const largestNumber = getLargestNumber([1, 9, 5]);
console.log(largestNumber, '<-- should be 9');
In JavaScript, you can use the
Math.max.apply()
function to do this, like so:This is like calling:
You can also do this with
Math.min
too.Hope this is what you were looking for!
However, I see your point, will try to not do this in future. Thanks for the feedback!
I recommend looking at this for more information.
However, if you want to post a Repl, it is recommended that you use the share Repl feature when you post the code (above the title).