Tell us what’s happening:
All tests are passed. Except “Should handle words without vowels.” Please help me to get through this.
Your code so far
function translatePigLatin(str) {
let startChar = str[0];
let vowelChar = /[^aeiou]/;
var firstVowelIndex;
let newStr = "";
firstVowelIndex = str.indexOf(str.match(/[aeiou]/g)[0]);
if(firstVowelIndex >0){
//if(vowelChar.test(str[0])){
newStr = str.slice(firstVowelIndex) + str.slice(0,firstVowelIndex)+ "ay";
}
if(firstVowelIndex ==0) {
newStr = str + "way";
}
if(firstVowelIndex < 0) {
newStr = str + "ay";
}
return newStr;
}
translatePigLatin("consonant");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin