function translate(str) { var arr = str.split("") var firLetter = arr[0] var secLetter = arr[1] var vowels = ["a","e","i","o","u"] for(i=0;i<vowels.length;i++){ if(firLetter==vowels[i]){ var newSt1 = arr.join("")+"way" return newSt1 } else if(secLetter==="a"){ arr.push(firLetter) arr.push(secLetter) arr.splice(0,1) var newSt = arr.join("")+"y" return newSt } else{ arr.push(firLetter) arr.push(secLetter) arr.splice(0,2) var newSt2 = arr.join("")+"ay" return newSt2 } } } translate("eight");