Tell us what’s happening:
I can’t get the last test to pass: ‘Should handle words without vowels.’
The code I created worked in the original freeCodeCamp Pig Latin challenge, but does not work in the new one. I have tried three ways of handling words without vowels
- return the word without changing it (if the original word is ‘bcd’ return ‘bcd’)
- add ‘ay’ to the end of the word (if the original word is ‘bcd’ return ‘bcday’)
- move the first constant to the end of the word and add ‘ay’ (if the original word is ‘bcd’ return ‘cdbay’)
I have created code that successfully performs each of these options. You can see this code at CodePen.
I also tried the solutions in the certificate section of the freeCodeCamp guide for Pig Latin. None of those worked either, even after I inserted the missing opening bracket in both the Basic and Intermediate Code Solutions.
I am not sure what to try next. Any suggestions?
Thanks
Your code so far
function translatePigLatin(str) {
return /^[^aeyiuo]+$/.test(str) ?
str :
// str.replace(/^([^aeiouy])(.*)/, '$2$1ay') :
// str + 'ay' :
str
.replace(/^([aeiouy])(.*)/, '$1$2way')
.replace(/^([^aeiouy]+)(.*)/, '$2$1ay');
}
translatePigLatin("bcd");
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 10176.68.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.144 Safari/537.36
.
Link to the challenge: