Created
February 27, 2013 14:48
-
-
Save johnstew/5048420 to your computer and use it in GitHub Desktop.
CoderByte Challenge: 3rd Largest Word
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 ThirdLargest(sArray){ | |
var oArray = {}; | |
for(i = 0; i <= sArray.length-1; i++){ | |
oArray[sArray[i]] = sArray[i].length; | |
} | |
var sortable = []; | |
for(x in oArray){ | |
sortable.push([x, oArray[x]]); | |
} | |
sortable.sort( function(a,b){ | |
return b[1] - a[1]; | |
}); | |
return sortable[2][0]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment