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

18 lines
592 B
JavaScript

export function longestWords(words) {
// implementar logica aqui
var longest = "";
for (var word of words) {
if (word.length > longest.length) longest = word;
}
return longest;
}
// Resultados esperados
console.log(longestWords(["abacaxi", "melancia", "banana"]))
console.log(longestWords(["aba", "aa", "ad", "vcd", "aba"]))
console.log(longestWords(["aa"]))
console.log(longestWords(["abc", "eeee", "abcd", "dcd"]))
console.log(longestWords(["aa", "bb", "cc"]))
console.log( longestWords([ "a", "abc", "cbd", "zzzzzz", "a", "abcdef", "asasa", "aaaaaa"]))