0

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");
jps_dot_dev
  • 65
  • 1
  • 13
  • It's not about the `console.log`, it's about the `consonants.test` invocation – Bergi Sep 21 '16 at 00:05
  • 1
    Oh god thank you! I have been trying to find the answer to this for hours, and have only gotten back irrelevant replies across the board. – jps_dot_dev Sep 21 '16 at 00:11

0 Answers0