Created
January 29, 2017 06:54
-
-
Save johncmunson/d75766159aadf6e77ec8b1236238a198 to your computer and use it in GitHub Desktop.
Accepts a word and returns the same word in pig latin
This file contains 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
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