Created
March 7, 2014 16:50
-
-
Save iilei/9415122 to your computer and use it in GitHub Desktop.
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
/** | |
Concatenating a Mystery String | |
Concatenate the digits of 8 5 6 2 3 7 into a new String where: | |
All even digits (the actual number) are spelled in lowercase English | |
All odd digits (the actual number) stay as regular numbers | |
All values in the final string are separated by a space | |
*/ | |
var temp = ""; | |
"8 5 6 2 3 7".split(" ").forEach(function(n) { | |
temp += ((n%2 == 0) ? ("two four six eight ten".split(" "))[n/2-1] : n) + " "; | |
}); | |
temp.replace(/ $/, ""); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what i do