function translatePigLatin(str) {
// consonant letters: b, c, d, f, g, h, j, k, l, m, n, p, q, r, s, t, v, w, x, y, z
// vowels: a, e, i, o, u,
// if str starts with a consonant letter or two consecutive consonant letters...return the str with the consonant letters at the end + ay
// if str starts with a vowel return the str with the vowel at the end + way
let vowels = /"aeiou"/g;
for (let i = 0; i < str.length; i++) {
if (str[0] == vowels) {
str.push(str[0]+"ay")
}
return str;
} if (str[0] !== vowels) {
str.push(str[0] && str[1] + "way")
}
return str;
}
translatePigLatin("consonant");
I feel like I understand what is going on but I just can’t get to a solution. Can someone please help me out without giving me any answer?