Last active
May 10, 2021 14:19
-
-
Save RahmatSaeedi/fa7bea306588ffd3e40cdc8119a68369 to your computer and use it in GitHub Desktop.
CodeSignal - Arcade - Intro - JS - All Longest Strings
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) { | |
let returnArray=['']; | |
for(let i = 0; i<inputArray.length; i++){ | |
if(inputArray[i].length > returnArray[0].length) { | |
returnArray = []; | |
returnArray.push(inputArray[i]); | |
} else if(inputArray[i].length == returnArray[0].length) { | |
returnArray.push(inputArray[i]); | |
} | |
} | |
return returnArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment