Tell us what’s happening:
I’m stumped. I seem to be geting the correct results, even for a word without a vowel but I can’t pass the check.
any suggestions?
Your code so far
function translatePigLatin(str) {
let regEx = /([aeiou]*)/i // match vowels
let regEx2 = /(^[aeiou]+)(.+)/i;
let regEx3 = /([^aeiou]*)(.+)/i
// console.log(str.match(regEx));
if (str.match(regEx2) === null || str.match(regEx) === null){ // first char ! a vowel
return str.replace(regEx3, '$2$1ay');
}
return str.concat('way');
}
translatePigLatin("consonant");
console.log(translatePigLatin("california"));
console.log(translatePigLatin("glove"));
console.log(translatePigLatin("algorithm"));
console.log(translatePigLatin("why"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin