The last case fails even though result is correct.
Your code so far
function translatePigLatin(str) {
var firstVowel = str.match(/[aeiou]/);
var firstPosition = str.indexOf(firstVowel);
if (firstPosition > 0) {
return str.slice(firstPosition) + str.slice(0, firstPosition) + 'ay';
}
return str + 'way';
}
console.log(translatePigLatin("rhythm"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin/