I got this thing thank you all who tried to help

I don’t have a word to describe it’s wired whats the problem when str passed is gloves?


function translatePigLatin(str) {
let halfWay;
let modified = str.split("").map(item => {
  if (item == 'a' ||
    item == 'o' ||
    item == 'i' ||
    item == 'e' ||
    item == 'u') {
    halfWay = str.indexOf(item);
    return item
  } else {
    return item
  }
});
for (let i = 0; i < modified.length; i++) {
  if (modified[0] == 'a' ||
    modified[0] == 'e' ||
    modified[0] == 'i' ||
    modified[0] == 'o' ||
    modified[0] == 'u') {
    return str + 'way'
  }
}

let final = modified.splice(halfWay, modified.length).concat(modified).join("");
return final + 'ay';
}

console.log(translatePigLatin("glove"));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36.

Challenge: Pig Latin

Link to the challenge:

what are you trying to do?

why are you mapping over an array to not change anything on it?
also halfWay will get the value of last vowel position - the e in glove in this case

why are you iterating on an array to check only its first element?

1 Like

What on earth are you trying to do? I tried to help you but what are you trying to achieve???