Pig Latin challenge, does not pass the last criterion

My code is giving me a string with consonants an ay at the end when I code in Repl.it editor but I cannot pass in FCC. Getting “Should handle words without vowels.”
Can anyone see what I made wrong?

function translatePigLatin(str) {
  let newStr = "";
  let kons = "";
  let r = /[aeoiuy]/;
  let res = str.indexOf(str.match(r));
  if(res === -1){
    newStr =  str + "ay";
  else if(res === 0 ){
    newStr = str + "way";
  }else {
    kons =str.slice(res);
    newStr = kons + str.slice(0,res) +"ay"
return newStr;


“y” is not a vowel.

In Swedish it is!
When I Google English vowels it says " These letters are vowels in English : A, E, I, O, U, and sometimes Y. It is said that Y is “sometimes” a vowel , because the letter Y represents both vowel and consonant sounds."

Thank you!! This solwed my problem!. Now I passed all tests :slight_smile:

This confusion is common for multi-lingual campers.

1 Like