Pig Latin Challenge Not Passing

Tell us what’s happening:
So, I have this code below, I’m not sure what I did wrong. When I tested it in my browser console and in CodePen, it worked just fine. Can anyone tell me why it’s not passing? Thank you :slight_smile:

Your code so far


function translatePigLatin(str) {
newStr = "";
if (str.search(/[aeiou]/) == 0) {
  newStr += str + "way";
} else if (/[aeiou]/.test(str) == false) {
  newStr += str + "ay";
} else {
  var index = str.search(/[aeiou]/);
  var consonants = str.substr(0, index);
  newStr = str.substr(index) + consonants + "ay";
}
return newStr;
}

console.log(translatePigLatin("california"));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36.

Challenge: Pig Latin

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin

Make sure you always explicitly declare variables you are referencing in your code.

Wow, that was a dumb mistake :expressionless: And I quadruple-checked every line except that one! Thank you so much! :smiley: