forked from M3-Academy/challenge-algorithms-v2.0
feat: Algoritmo 10-longestWords - finalizado
This commit is contained in:
parent
6d4c4c3b53
commit
1d740bcc00
@ -1,4 +1,20 @@
|
|||||||
export function longestWords(words) {
|
export function longestWords(words) {
|
||||||
// implementar logica aqui
|
// implementar logica aqui
|
||||||
|
let count = 0;
|
||||||
|
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;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user