Tell us what’s happening:
Hey guys, I’m trying to pass this 2 test, but I can’t:
- Should handle words where the first vowel comes in the end of the word.
- Should handle words without vowels.
Could someone help me understand this topics?
D
Your code so far
function translatePigLatin(str) {
if (/^([b-df-hj-np-tv-z]){2,}/.test(str.slice(0, 2))) {
const con = str.slice(0, 2);
let _str = str.slice(2);
return _str + con + "ay";
}
if (/^([b-df-hj-np-tv-z]){1,}/.test(str.slice(0, 1))) {
const con = str.slice(0, 1);
let _str = str.slice(1);
return _str + con + "ay";
}
return str + "way";
}
translatePigLatin("consonant");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin