Created
February 25, 2017 23:09
-
-
Save Underdoge/6a1e3e2e8261ab3f9aebb81ac8da44d3 to your computer and use it in GitHub Desktop.
allLongestStrings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function allLongestStrings(inputArray) { | |
var result=[""]; | |
var count=0; | |
for(var i=0;i<inputArray.length;i++){ | |
if(inputArray[i].length>=result[result.length-1].length){ | |
if(inputArray[i].length>result[result.length-1].length) | |
count=1; | |
else | |
count++ | |
result.push(inputArray[i]); | |
} | |
} | |
return result.slice(result.length-count);; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A shorter way:
`function allLongestStrings(inputArray) {
}
`