Hello,
I have a problem with a task Intermediate Algorithm Scripting: Pig Latin.
It seems to me that all conditions are there to pass this task, but I still get the alert that my code doesn’t handl words without vowels.
I am not quite sure where is the problem.
**my code so far:
function translatePigLatin(str) {
const firstRegex = /^[aeiouy]/gi
const vowelsRegex = /[aeiouy]/gi
if(str.match(vowelsRegex) === null){
str = str + "ay";
return str;
} else if(!firstRegex.test(str)){
const firstVowel = str.search(vowelsRegex);
const ending = str.slice(firstVowel, str.length);
const begin = str.slice(0, firstVowel);
str = ending.concat(begin).concat("ay");
return str;
}else{
str = str.concat("way");
return str
}
}
console.log(translatePigLatin("concat"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1) 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