longetWords
This commit is contained in:
parent
c32afac722
commit
17e2ecc796
@ -1,4 +1,18 @@
|
||||
export function longestWords(words) {
|
||||
// implementar logica aqui
|
||||
|
||||
}
|
||||
let longest = '';
|
||||
|
||||
for (const word of words) {
|
||||
if (word.length > longest.length) {
|
||||
longest = word;
|
||||
}
|
||||
}
|
||||
|
||||
return words.filter((word) => word.length === longest.length);
|
||||
}
|
||||
|
||||
console.log(longestWords(["abacaxi", "melancia", "banana"])); // ['melancia']
|
||||
console.log(longestWords(["aba", "aa", "ad", "vcd", "aba"])); // ["aba","vcd", "aba"]
|
||||
console.log(longestWords(["aa"])); // ["aa"]
|
||||
console.log(longestWords(["abc", "eeee", "abcd", "dcd"]));//["eeee", "abcd"]
|
||||
console.log(longestWords(["aa", "bb", "cc"]));//["aa", "bb", "cc"]
|
||||
console.log(longestWords(["a", "abc", "cbd", "zzzzzz", "a", "abcdef", "asasa", "aaaaaa"]));//["zzzzzz", "abcdef", "aaaaaa"]
|
||||
|
Loading…
Reference in New Issue
Block a user