Skip to content

Instantly share code, notes, and snippets.

@RP-3
Created August 19, 2020 07:22
Show Gist options
  • Save RP-3/a748aa00226c1d4d705137be010526ee to your computer and use it in GitHub Desktop.
Save RP-3/a748aa00226c1d4d705137be010526ee to your computer and use it in GitHub Desktop.
/**
* @param {string} S
* @return {string}
*/
const v = 'aeiouAEIOU';
var toGoatLatin = function(S) {
return S.split(' ')
.map((w, i) => (v.indexOf(w[0]) >= 0 ? w : (w.slice(1) + w[0])) + 'ma' + 'a'.repeat(i+1))
.join(' ');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment