# What are the rules of Pig Latin

Tell us what’s happening:
can someone explain to me the directions of this challenge, what is meant by consonant cluster?
also, what i wrote is not satisfying the 5th condition however it does return “eightway” on the second run of the loop bc thats where i put e in the arr. how can I break out of the loop and only return it when it satisfies the condition?

Your code so far

``````
function translatePigLatin(str) {
var arr= ["a","e","i","o","u"];
for (var i=0; i<arr.length; i++){
if (str.charAt(0)== arr[i]){
return str+"way";
} else {
return str.substring(1)+str.charAt(0)+"ay";
}
}
}
translatePigLatin("algorithm");
``````

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

consecutive consonants like ‘sch’ in the word ‘school’

Not understanding what you mean by “it does return “eightway” on the second run of the loop”. Your for loop only makes one iteration for the test case translatePigLatin(“eight”) and returns “ighteay” instead of “eightway”.

In the first iteration i=0, so your if statement checks if “e” is equal to “a”. It is not, so your else block of code executes.

The only way your code would return “eightway” for the test case (translatePigLatin(“eight”), would be if you only had the following code in your function.

``````  var arr = ["a", "e", "i", "o", "u"];
for (var i = 0; i < arr.length; i++) {
if (str.charAt(0) == arr[i]) {
return str + "way";
}
}
``````

Of course, you would need other logic to handle what to do in other test cases. The above loops through arr until a vowel is found which matches the first character of str.