Tell us what’s happening:
please help this is starting to give me headache. When i run word like “WHY” this is return “YWHAY”. but this “Should handle words without vowels.” is not passed. PLEASE PLEASE HELP
Your code so far
function translatePigLatin(str) {
var x = str.match(/[aeiou]/);
var y = str.indexOf(x);
if(y > 0) {
return str.slice(y) + str.slice(0, y) + 'ay'
} else if(y === -1) {
return str.slice(length - 1) + str.slice(0, length - 1) + 'ay'
}
return str + 'way';
}
translatePigLatin("why");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin