forked from M3-Academy/challenge-algorithms-v2.0
19 lines
473 B
JavaScript
19 lines
473 B
JavaScript
export function longestWords(words) {
|
|
// implementar logica aqui
|
|
let strFinal = [''];
|
|
|
|
for(let i = 0; i < words.length; i++){
|
|
|
|
if(words[i].length >= strFinal[0].length){
|
|
if(strFinal[0].length === '' || strFinal[0].length < words[i].length){
|
|
strFinal.length = 0;
|
|
strFinal.push(words[i]);
|
|
}else{
|
|
strFinal.push(words[i]);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return strFinal;
|
|
} |