Pig Latin - cannot pass last 2 tests

Tell us what’s happening:

Hi everybody,
I’m stuck on the “Pig Latin” exercise, I cannot pass the last 2 tests and I don’t understand why.

1* Should handle words where the first vowel comes in the end of the word.
2* Should handle words without vowels.

I tested the function with words with the vowel in the end of the word and without vowels, it looks ok to me… Am I missing something? :thinking:

Your code so far

function translatePigLatin(str) {
  var cons = "bcdfghljklmnpqrstvz";
  var vow = "aeiou";
  var c = [];
  var i = 0;

  var str = str.split("");
    return str.slice(i,str.length).join("") + c.join("") + "ay";
    return str.join("") + "way";


Your browser information:

First, rather than returning directly as you have, I might suggest storing the value you’ll return to a variable. This will let you console.log() that variable just before you return that value.

That said, for the purposes of this challenge, ‘y’ is not a vowel. It doesn’t appear to be either vowel or consonant in your strings though. For some reason, you also seem to not like ‘w’ very much, as it is neither a consonant or vowel either… :wink:

Thank you @snowmonkey!
I just realized that I didn’t put x in the cons string as well (in Italy they are not part of our alphabet, that’s why I forgot ahah)!
I added them and now woks correctly :slight_smile:

Yes I always store the parameter/s in another variable, I don’t know why this time I didn’t :confused:

1 Like

Well, and you don’t NEED to, in this case, unless you want to be able to throw them out for debug purposes.

And yeah, the language thing becomes a challenge. Doing great, though. keep it up! :wink:

1 Like