Where is my Pig Latin failing?

Tell us what’s happening:
So, i’m unsure of what the algorithm is asking for, I can’t think of an example that doesn’t give back correct pig latin.

Your code so far


function translatePigLatin(str) {
  var firstLetter = str.charAt(0); 

  function isVowel(x){

    var result;

    result = x == "a" || x == "e" || x == "i" || x == "o" || x == "u";
    return result;
  }

  if(isVowel(firstLetter)){
    return str.concat("way"); 
  }

  else{
    if(!isVowel(firstLetter) && isVowel(str.charAt(1))){
      return str.substring(1, str.length).concat(firstLetter).concat("ay");
    }
    else{
      return str.substring(2, str.length).concat(str.substring(0, 2)).concat("ay");
    }
  }

}

translatePigLatin("glove");

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Link to the challenge:

Your solution assumes that a vowel will always be the first, second, or third letting in the string.

If you do

translatePigLatin("strength");   // will be "rengthstay", should be "engthstray"

Your code can’t handle words that have a bigger cluster of consonants at the beginning. Or words without vowel.

translatePigLatin("bcdfghjk"); // will be "dfghjkbcay", should be "bcdfghjkay"