I am trying to find all the longest strings in an array.
For inputArray = ["aba", "aa", "ad", "vcd", "aba"], the output should be
allLongestStrings(inputArray) = ["aba", "vcd", "aba"].
So far I have the code
function allLongestStrings(inputArray) {
let longboys = []
for (i = 0; i < inputArray.length; i++) {
if (inputArray[i].length) {
// what to do here
longboys.push()
}
}
return longboys
}
I am stumped on how to find the longest string and then use the length of that string to add others to the array.
Sorry if this has already been answered elsewhere, I've been finding lots of "find the longest string in an array" but nothing on finding multiple.