Pig Latin(Problem)

translatePigLatin("glove") should return “oveglay”.
Not able to pass the above test,its a consonant-first-letter word,which shouls be lovegay as per instructions

console.clear()

function translatePigLatin(str) {
  let word = 'abcdefghijklmnopqrstuvwxyz'
  let split = word.split('')
  let vowels = []
  let consonants = []
  let vowelStr
  let consonantStr 
  for(let i = 0;i<split.length;i++) {
    if(split[i] === 'a' || split[i] === 'e' || split[i] === 'i' || split[i] === 'o' || split[i] === 'u') {
      vowels.push(split[i])
    }
    else {
      consonants.push(split[i])
    }
  }
  for(let j = 0;j<vowels.length;j++) {
    if(str[0] === vowels[j]) {
      //console.log("vowel")
      let splittedArr = str.split('')
      //let shiftedVal = splittedArr.shift()
      let joined = splittedArr.join('')
      vowelStr = joined + 'way'
      //console.log(vowelStr + 'way')
    }
  }
  for(let k = 0;k<consonants.length;k++) {
    if(str[0] === consonants[k]) {
      //console.log('consonant')
      let splittedArr2 = str.split('')
      let shiftedVal2 = splittedArr2.shift()
      let joined2 = splittedArr2.join('')
      consonantStr = joined2 + shiftedVal2 + 'ay'
    }
  }
  
  //console.log(vowels)
  //console.log(consonants)
  return vowelStr || consonantStr
}

console.log(translatePigLatin("consonant"))

According to the instructions:

Pig Latin takes the first consonant (or consonant cluster) of an English word, moves it to the end of the word and suffixes an “ay”.

In this case, “gl” would be a “consonant cluster”.

And important part of being a good developer is paying very close attention to minute details. Just keep at it - you’ll get it.