2022-10-27 15:07:13 +00:00
|
|
|
export function longestWords(words) {
|
|
|
|
// implementar logica aqui
|
2022-11-02 21:09:01 +00:00
|
|
|
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"]))
|