Tell us what’s happening:
Can someone guide me whats the problem in my code ? I have checked my code with different inputs at developer.mozzila.org with console.log in replace of return and its working fine.
Your code so far
function translatePigLatin(str) {
var newName = ""
var check = ["a","e","i","o","u"]
for(let i = 0; i <str.length;i++)
{
if(check.includes(str[i]) == true)
{
newName = str.slice(i)
let j = i
i = str.length - 1
if (newName.length == str.length)
{
newName = newName + "way"
}
else{
newName = newName + str.slice(0,j) +"ay"
}
}
else {
newName = ""
}
}
return newName
}
translatePigLatin("rhythm");