Tell us what’s happening:
Hello,
Would you please somebody explain why the order of replace() methods is crucial in solution 4 in order to work?
Thanks!
Your code so far
function translatePigLatin(str) {
return str
.replace(/^[aeiou]\w*/, "$&way")
.replace(/(^[^aeiou]+)(\w*)/, "$2$1ay");
}
translatePigLatin("consonant");
Challenge: Pig Latin
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin