var valores = [1, true, "hola", "adios", false];
var palabras = valores.filter((p) => typeof p == 'string');
var masLarga = palabras.filter((p) => typeof p == 'string').reduce((acc, element, idx) => {
acc = element.length > acc.length ? element : acc
return acc;
}, "");
console.log(masLarga);
Jenkins
- 21
- 2