Pig Latin challenge problem?

Hi fellows

please, can someone here tell me what’s wrong with my code? it doesn’t work for me even if it seems to me logic.

function translatePigLatin(str) {
  if(str[0] == "a" | str[0] == "e" | str[0] == "y" | str[0] == "u" | str[0] == "i" | str[0] == "o"){
    return str.concat("way")
  } else{
    return str.replace(str[0], "").concat(str[0] + "ay")
  }
  //return str;
}

translatePigLatin("consonant");
1 Like

You are just checking the first letter
glove becomes lovegay
Instead you should move the consonant cluster (any number of consonants) from the beginning to the end glove -> oveglay

2 Likes

yes you’re right i forgot that :),i will try to figure it out

1 Like

Also, for the purposes of this exercise, ‘y’ is considered not a vowel. So, in addition to having words with no starting consonant (eater), you have one (beater) or two (cheater) or more (schemer) or none at all (hymn).

1 Like

Thanks a lot @ilenia & @snowmonkey finally i figure it out and i solve it :slight_smile: