Tell us what’s happening:
I am stuck. I tried all solutions from Hints. However, nothing works.
Your code so far
function translatePigLatin(str) {
return str
.replace(/[1]\w*/, “$&way”)
.replace(/([2]+)(\w*)/, “$2$1ay”);
}
// test here
translatePigLatin(“consonant”);
function translatePigLatin(str) {
return str
.replace(/^[aeiou]\w*/, "$&way")
.replace(/(^[^aeiou]+)(\w*)/, "$2$1ay");
}
// test here
translatePigLatin("consonant");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.53
Challenge: Intermediate Algorithm Scripting - Search and Replace
Link to the challenge: