Skip to content

Instantly share code, notes, and snippets.

@iilei
Created March 7, 2014 16:50
Show Gist options
  • Save iilei/9415122 to your computer and use it in GitHub Desktop.
Save iilei/9415122 to your computer and use it in GitHub Desktop.
/**
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(/ $/, "");
@iilei
Copy link
Author

iilei commented Mar 7, 2014

I'd say I have used string concatenation ...

@arun99178
Copy link

what i do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment