Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
JavaScript Interview Question: Largest integer in array?
Return the largest value in an array of non-negative integers
function largestInt(arr) {
if (arr.length === 0) {
return -1;
return arr.reduce(comparator);
const comparator = ((largestValue, element) => largestValue > element ? largestValue : element);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.