Intermediate Algorithms. Pig Latin Stuck

Hi everyone!! Please need some help, My code check positive all except the last ones, I don’t know what i have to add

function translatePigLatin(str) {
  var consonantVowel = str.slice(0, 1)
  var consonantConsonant = str.slice(0, 2)
if ('aeiou'.indexOf(str[0]) > -1) {
  return str + 'way'
} 
  else if (('aeiou'.indexOf(str[0]) === -1) && ('aeiou'.indexOf(str[1]) > -1)) {
    return str.slice(1).concat(consonantVowel) + 'ay'
}
  else if (('aeiou'.indexOf(str[0]) === -1) && ('aeiou'.indexOf(str[1]) === -1)) {
    return str.slice(2).concat(consonantConsonant) + 'ay'
  }
}
translatePigLatin("consonant");

Passed - translatePigLatin("california") should return “aliforniacay”.

Passed -translatePigLatin(“paragraphs”)` should return “aragraphspay”.

Passed - translatePigLatin("glove") should return “oveglay”.

Passed - translatePigLatin("algorithm") should return “algorithmway”.

Passed - translatePigLatin("eight") should return “eightway”.

**Not yet - Should handle words where the first vowel comes in the end of the word. **

Not yet - Should handle words without vowels.

Look at your code, line by line… do you have anywhere code that can handle a word like strength? (It returns “rengthstay”)

Your code is checking only the letters at index 0 and at index 1, never checking others. What if the letters at index 2and 3 are also consonants? You need to refactor your code.

I redesign my code but now they told me the last one still missing… what could be an example of the output?? Thanks!!

function translatePigLatin(str) {
  const vowels = (/[aeiou]/ig)
  let newWord = ""
  const vowelIdx = str.indexOf(str.match(vowels)[0])
  if (str[0].match(vowels)) {
    newWord = str + 'way'
  } else {
    newWord = str.substring(vowelIdx) + str.substring(0, vowelIdx) + 'ay'
  }
  return newWord
}

Should handle words without vowels.