-4
- Write a function that returns the largest string given.
example:
entree: "Stackoverflow" "No Response" "Tags"
exit:
"Stackoverflow" // string with the largest number of characters.
-4
example:
entree: "Stackoverflow" "No Response" "Tags"
exit:
"Stackoverflow" // string with the largest number of characters.
5
You don’t need to write a function that already exists, use Array.prototype.reduce()
var strings = ["StackOverflow", "Sem resposta", "Tags"];
var retorno = strings.reduce(function (atual, proximo) {
return atual.length > proximo.length ? atual : proximo;
});
alert(retorno);
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.
what have you done to try to get to it? Show your code if possible
– Marcos Henrique
Sometimes a simple google search returns the answer.
– lys