Pig Latin not accepting the answer

I have done the pig latin challenge, it returns the right values, but still the FreeCodeCamp app shows that it is not good. Can somebody tell me what is wrong here?

Link to the challenge:

You aren’t returning anything from your translatePigLatin() funciton.

1 Like

Ou… I see now! I thought that if I am returning something from the inner function that it will also be return from the main function. Thanks a lot! :smile:

If you want to check all letters just use string.toLowerCase()

There is my solution if you interested.
Also strange why hint section don’t have examples with slice().

function translatePigLatin(str) {

    let vowels = /[aeiou]/;
    let check = str.match(vowels);
    let word = "";

    if(!check) {
        word = str + "ay";
    } else if (check.index === 0) {
        word = str + "way";
    } else {
        word = str.slice(check.index) + str.slice(0, check.index) + "ay";

    return word;


Edit… oh what… 1 year later post… I thought its 2018-09-17 … my bad :E