Skip to content

Instantly share code, notes, and snippets.

@johncmunson
Created January 29, 2017 06:54
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 johncmunson/d75766159aadf6e77ec8b1236238a198 to your computer and use it in GitHub Desktop.
Save johncmunson/d75766159aadf6e77ec8b1236238a198 to your computer and use it in GitHub Desktop.
Accepts a word and returns the same word in pig latin
const pigLatin = str => {
let pigStr = "";
const key = ["a", "e", "i", "o", "u"];
if (key.some(val => val === str.charAt(0))) {
pigStr = str + "way";
return pigStr;
} else {
pigStr = str.slice(1) + str.charAt(0) + "ay";
return pigStr;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment