freeCodeCamp Challenge Guide: Longest string challenge

Longest string challenge


Solutions

Solution 1 (Click to Show/Hide)
function longestString(strings) {
  const maxLength = strings.reduce(
    (maxLength, string) => Math.max(maxLength, string.length),
    0);
  return strings.filter((string) => string.length == maxLength)
}
3 Likes