I have been having issues with this Code Excercise, my while loop does not repeat if you remove the final console.log() statement. Not only that but it evaluates to false in console.log() which makes me question why the loop even runs at all, and also when the webpage tests the code to see if it outputs 'eightway' it fails it despite the program returning 'eightway.'
Thanks
var consonants = /[^aeiou]/ig;
var vowels = /[aeiou]/ig;
function translatePigLatin(str) {
if (vowels.test(str[0])) {
str = str.concat('way');
return str;
}
str = str.split('');
while (consonants.test(str[0])) {
var shifted = str.shift();
str.push(shifted);
console.log(consonants.test(str[0]));
}
return str.join('') + 'ay';
}
translatePigLatin("eight");