Tell us what’s happening:
I am getting error as title says: Should handle words without vowels.
I have checked on different enviroment it gives correct output without vowels.
I am not sure where it is the mistake. Also if you can tell me how to improve my code I’d appreciate it .
thanks in advance
Your code so far
function translatePigLatin(str) {
let index= 0;
if (str[0]==="a"||str[0]==="i"||str[0]==="o"||str[0]==="y"||str[0]==="e"){
return str+"way";
}
else {
for(let i of str){
if(i === "a" || i === "i" || i === "o" || i === "y" || i === "e"){
break;
}
index++;
}
}
return str.slice(index)+str.slice(0,index)+"ay"
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) 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