feat: criar algoritmo que retorne as palavras longas de uma lista de palavras

This commit is contained in:
HUMBERTO ANTONIO CORREIA FERRO 2022-10-31 10:11:20 -03:00
parent 68ff6206f7
commit cfdec8e85d

View File

@ -1,4 +1,14 @@
export function longestWords(words) {
// implementar logica aqui
let newArr = [];
let long = 0;
words.forEach(function(element){
if(element.length > long){
long = element.length
}
});
newArr = words.filter(element =>
element.length == long
);
return newArr;
}