Merge pull request 'feat(home):resolucao da questao 10' (#10) from feature/exercicio10 into development

Reviewed-on: #10
This commit is contained in:
Edna Barboza de Lima 2022-10-29 02:57:51 +00:00
commit a3c6be8a5a

View File

@ -1,4 +1,20 @@
export function longestWords(words) { export function longestWords(words) {
// implementar logica aqui let allArray = [];
let longest = [];
for (let i=0; i<words.length; i++){
if(longest < words[i].length){
longest = words[i].length;
}
}
for(let j =0; j < words.length; j++){
if(words[j].length == longest){
allArray.push(words[j]);
}
}
if(allArray.length == 1){
return allArray[0].split()
}else{
return allArray
}
} }