Created
July 26, 2014 03:11
-
-
Save alexdiliberto/3f66e0a26256ca78c16a to your computer and use it in GitHub Desktop.
rövarspråket
This file contains hidden or 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
| /* | |
| Double every consonant and place an occurrence of "o" in between. | |
| For example, translate("this is fun") should return the string "tothohisos isos fofunon". | |
| translate('this is fun') | |
| => "tothohisos isos fofunon" | |
| */ | |
| function translate(str) { | |
| var arr = str.split(''), | |
| out = ""; | |
| arr.forEach(function(letter) { | |
| if (!!~" aeiou".indexOf(letter)) { | |
| out += letter; | |
| } else { | |
| out += (letter + 'o' + letter); | |
| } | |
| }); | |
| return out; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment