challenge-algorithms-v2.0-G.../10-longestWords/index.js

9 lines
360 B
JavaScript
Raw Normal View History

export function longestWords(words) {
// implementar logica aqui
return words.reduce((longWords, currentWord) => {
if(!longWords[0] || longWords[0].length < currentWord.length) return [currentWord];
if(longWords[0].length > currentWord.length) return longWords;
longWords.push(currentWord);
return longWords;
},[])
}