Help with Pig Latin problem

Tell us what’s happening:

Hi! I have written the beginnings of what I feel should be a good solution to this problem, but for some reason within my else statement where i try to execute

fst += arr.shift()

It absolutely refuses to take anything from arr or modify it in any way! I have actually tried several different methods and for some reason, within the “else” statement it won’t let me modify arr at all. I’m not really sure what I’m doing wrong here or what I’m missing. Is there some rule against using methods to modify arrays in a different section of the function? I’ve been beating my head against this for an hour or so and nothing I’ve tried or googled has helped me in any way, so any help is appreciated.

Your code so far

function translatePigLatin(str) {
  let arr = str.split("");
  let vowels = ['a', 'e', 'i', 'o', 'u'];
  let fst = '';
  if (vowels.includes(arr[0])) {
    str = arr.join('') + "way";
  else {
    for (let i = 0; i < arr.length; i++) {
        if (vowels.includes(arr[i]) === true) 
          for (let j = 0; j < i; j++) {
            fst += arr.shift();
          str = arr.join('') + 'ay';
          i = arr.length;
  return str;


Your browser information:

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

Link to the challenge:

Ah, I had forgotten to wrap the if statement within the for loop with brackets. Silly mistake, I should have noticed it earlier.