Tell us what’s happening:
My code is not passing the last test when it is working perfectly in the browser console.
The last test says : Should handle words without vowels.
Your code so far
function translatePigLatin(str) {
let result;
if(/[^aeiou]+/.test(str) === true){
result = str+"way";
}
if(str.match(/(^[^aeiou]+)/) !== null){
let sub2 = str.replace(/(^[^aeiou]+)(\w+)/,"$1 $2");
let arr = sub2.split(" ");
result = `${arr[1]}${arr[0]}ay`
}else{
result = str+"way";
}
return result;
}
translatePigLatin("hhhjjjhhhjjj");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin