Skip to content

Instantly share code, notes, and snippets.

@johnstew
Created February 27, 2013 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnstew/5048420 to your computer and use it in GitHub Desktop.
Save johnstew/5048420 to your computer and use it in GitHub Desktop.
CoderByte Challenge: 3rd Largest Word
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