Hi,
Here is my solution for the pig latin question in the Intermediate algorithms section:
function translatePigLatin(str) {
let regex = /^[^aeiou]+/
let consonantResult = "";
if (regex.test(str)) {
consonantResult = str.match(regex)
return str.replace(consonantResult, " ").split(",").concat(consonantResult, 'ay').join("")
} else {
return str.split(",").concat('way').join("")
}
}
When running this in a js environment (repl it) I get the output as required in each test as per the FCC page for this question.
However, when I try to run it in the FCC page the only tests that pass are for ‘algorithm’ and ‘eight’.
I’ve been trying to figure this out but i just can’t, as far as repl it is concerned i’m getting the required output
Can anyone suggest where the problem is here?
Any help appreciated,
Many thanks,
Charlotte