Tell us what’s happening:
The last test is not passing and everything seems to be working fine.
Your code so far
function translatePigLatin(str) {
var firstVow = str.match(/[aeiou]/);
var firstPos = str.indexOf(firstVow);
//console.log(firstVow);
//console.log(firstPos);
if(firstPos > 0){
return str.slice(firstPos)+str.slice(0,firstPos)+ "ay";
}
return str + "way";
}
console.log(translatePigLatin("rhythm"));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36
.
Challenge: Pig Latin
Link to the challenge: