Last active
January 5, 2017 00:47
-
-
Save ian-bartholomew/9e973ddfa0d3425229f642f78306cc3f to your computer and use it in GitHub Desktop.
Codewars JS
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 order(words){ | |
// return empty string for undefined | |
if (words === undefined) { | |
return ''; | |
} | |
let rval = []; | |
let pieces = words.split(' '); | |
for (let i=0; i<10; i++) { | |
if (pieces.hasOwnProperty(i)) { | |
let piece = pieces[i].match(/\d/); | |
if (piece) { | |
rval[piece[0]] = piece.input; | |
} | |
} | |
} | |
return rval.join(' ').trim(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment