Skip to content

Instantly share code, notes, and snippets.

@alexdiliberto
Created July 26, 2014 03:11
Show Gist options
  • Select an option

  • Save alexdiliberto/3f66e0a26256ca78c16a to your computer and use it in GitHub Desktop.

Select an option

Save alexdiliberto/3f66e0a26256ca78c16a to your computer and use it in GitHub Desktop.
rövarspråket
/*
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