Tell us what’s happening:
The task does not specify how to handle words without vowels, so in order to complete the task, how to handle words without vowels?
Your code so far
function translatePigLatin(str) {
const voc = 'aeiouy';
if(voc.includes(str[0])) {
return str + 'way';
} else {
let i = 0;
while (i<str.length && !voc.includes(str[i])) {
i++;
}
if(i == str.length){
// word without vowels?, the task does not specify how to handle
return str + 'ay'; // does not pass!
}
return str.slice(i) + str.slice(0,i) + 'ay' ;
}
}
console.log(translatePigLatin("qwrt")); // word without wovels, but it does not pass with 'qwrtay', why?
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin