re: Keeping Your Code Simple VIEW POST

FULL DISCUSSION
 

I would probably go for a combo prototype/function.

// Can be used as-is
function longestString(first, second) {
  return second.length > first.length ? second : first
}

// But the prototype makes it more natural to read later
Array.prototype.longest = function() {
  return this.reduce(longestString, '')
};

// You know the winner is and will forever be..
const languages = [ 'javascript', 'php', 'ruby', 'python' ]

languages.longest() // "javascript" 😎
code of conduct - report abuse