Tell us what’s happening:
My solution is working, but validation is not accepting the last two points.
But
translatePigLatin(“zza”) outputs azzay
and
translatePigLatin(“bbb”) outputs bbbay
Could you please tell me what’s the problem?
Your code so far
function translatePigLatin(str) {
str = str.replace(/(^[bcdfghjjlmnpqrstvxz]+)?(\w*)/i, (p1, p2, p3) => {
if (p2 !== undefined) {
return `${p3}${p2}ay`;
} else {
return `${p3}way`;
}
});
return str;
}
translatePigLatin("consonant");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin