I am writing a script that will convert the string the user has entered into pig latin. I have that down, but I want to change the rules slightly so that the words are only changed if the word begins with a consonant. I was thinking of doing one of two things:
var vowel = a, e, i, o, u; //is this even possible?
function pigLatin(theArray)
//there is other code in the function I don't need help
//with, just what's below.
if ( string.charAt(0) == vowel )
{
//body statements here. i.e. don't change word and just
return it unchanged;
}
or
if ( string.charAt(0) == "a" || string.charAt(0) == "e" ||
string.charAt(0) == "i" || string.charAt(0) == "o" ||
string.charAt(0) == "u" )
{
//body statements. same as above;
}
or if there is an easier way...let me know.
Thanks alot
Mark
var vowel = a, e, i, o, u; //is this even possible?
function pigLatin(theArray)
//there is other code in the function I don't need help
//with, just what's below.
if ( string.charAt(0) == vowel )
{
//body statements here. i.e. don't change word and just
return it unchanged;
}
or
if ( string.charAt(0) == "a" || string.charAt(0) == "e" ||
string.charAt(0) == "i" || string.charAt(0) == "o" ||
string.charAt(0) == "u" )
{
//body statements. same as above;
}
or if there is an easier way...let me know.
Thanks alot
Mark