Skip to content

Instantly share code, notes, and snippets.

@arapehl
Created April 4, 2013 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arapehl/5307205 to your computer and use it in GitHub Desktop.
Save arapehl/5307205 to your computer and use it in GitHub Desktop.
A very simple pig latin translator. Won't handle capitals or punctuation.
function pigLatin(phrase) {
var arr, pigged;
arr = phrase.split(" ");
pigged = arr.map(function (word) {
var first, rest;
first = word.substring(0, 1);
rest = word.substring(1);
return rest + first + "ay";
});
return pigged.join(" ");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment