Tell us what’s happening:
Describe your issue in detail here.
I spent five hours trying to figure out what the problem is, pls, someone should look into my code and tell me what is wrong
Your code so far
function translatePigLatin(str) {
let vowel = /[aeiou]gi/;
let pigLatin = "";
if (str[0].match(vowel)) {
pigLatin = str + "way";
} else if
(str.match(vowel) === null) {
pigLatin = str + "ay"
} else {
let firstVowel = str.indexOf(str.match(vowel)[0]);
pigLatin = str.substr(firstVowel) + str.substr(0, firstVowel) + "ay"
}
return pigLatin
}
console.log(translatePigLatin("consonant"));
Your browser information:
User Agent is: Mozilla/5.0 (Linux; Android 11; TECNO LE6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.98 Mobile Safari/537.36
Challenge: Intermediate Algorithm Scripting - Pig Latin
Link to the challenge: