Tell us what’s happening:
Your code so far
function translatePigLatin(str) {
let newRegex = /([^aeiou])/gi;
if (newRegex.test(str[0]) && newRegex.test(str[1])) {
return str.slice(2)
+ str[0]
+ str[1]
+ "ay";
} else if (newRegex.test(str[0])) {
return str.slice(1)
+ str[0]
+ "ay";
}
return str + 'way';
}
translatePigLatin("consonant");
newRegex.test(str[1])
This regex evaluates to FALSE for letter l in “glove” :o , i don’t get why…whereas in regexone , it evaluates to true , see : https://regex101.com/r/8u5be3/1 , in dev console , it is false… help is welcome !
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
.
Link to the challenge: