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

19 lines
471 B
JavaScript

export function longestWords(words) {
// implementar logica aqui
let longWords = [];
let longLength = 0;
words.map(
(word) => {
if(word.length > longLength){
longLength = word.length;
longWords.splice(0, longWords.length);
longWords.push(word);
}
else if(word.length === longLength)
longWords.push(word);
}
);
return longWords;
}