Tell us what’s happening:
Hi ! Could you tell me why this code is not accepted? It says “Should handle words without vowels” but I think it does (check with “Pfft” it returns “Pfftay”).
Thanks!
Your code so far
function translatePigLatin(str) {
let temp = str;
let regex = /^[zrtpqsdfghjklmwxcvbn]+/;
var begin = temp.match(regex);
temp = temp.replace(regex, "");
if(begin != null) return temp+begin+"ay"
else return temp+"way";
return begin;
}
console.log(
translatePigLatin("pfft")
);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin