Last active
August 29, 2015 14:03
-
-
Save frayhan32/c44fde92c010577ea3a9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Pig Latin Translator Project | |
// Created By Faris Rayhan | |
// Copyrgiht 2014 | |
// This function will add the string at the end of string which begin by vocal with "-way" | |
// If begin with consonant the consonant word will be moved at the end of string plus "ay" | |
function toLatin(englishWord){ | |
var string = englishword ; | |
var vowel = ['a','i','u','e','o']; | |
var result = ''; | |
//If start with vocal | |
if(vowel.indexOf(string.charAt(0))!==-1){ | |
result = englishword +'-way' | |
}else{ | |
for(var i=0;i<=string.length-1;i++){ | |
if(vowel.indexOf(string[i])!==-1){ | |
result = string.substr(i,string.length)+"-"+string.substring(0,i)+"ay"; | |
break ; | |
} | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment