Pig Latin: code returns expected values, but tests fail. Bug?

Pig Latin: code returns expected values, but tests fail. Bug?
0.0 0

#1

As far as I can tell, the code that I have written for the Pig Latin challenge is working and returning the values expected for each test.

const vowels = ["a", "e", "i", "o", "u"];

function translatePigLatin(str) {
  var count = countInitialConsonants(str);
  if (startsWithVowel(str)) {
    str += "way";
  } else {
    var letters = str.split('');
    var consonants = letters.splice(0, count).join('');
    str = letters.join('') + consonants + "ay";
  }
  return str;
}

function startsWithVowel(word) {
  return vowels.includes(word[0]);
}

function countInitialConsonants(word) {
  var chars = word.split('');
  for (var i = 0; i < chars.length; i++) {
    if (vowels.indexOf(chars[i]) > -1) {
      return i;
    }
  }
  return 0;
}

translatePigLatin("glove");

Am I missing something, or is this a bug?


#2

What do the failing tests say?


#3

Strange. The failing tests are no longer failing after returning to the Pig Latin challenge. The tests are all passing now. Perhaps the page just needed a refresh.