Pig latin -why won't this non-regex solution work please?

Tell us what’s happening:

Hi guys, I see that the recommended solutions are using regex, why won’t my code below work? It seem to be identifying and changing the words that begin with a consonant, but other words that start with a vowel it doesn’t work for. Any feedback would be much appreciated. Thanks!

  **Your code so far**
function translatePigLatin(str) {

let start = str[0];
let noCons = str.slice(1,);
let result = "";


if (start = "a"||"e"||"i"||"o"||"u") {
return result = str + "way";
} else result = noCons + start + "ay";


  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0

Challenge: Pig Latin

Link to the challenge:

You need to move the first consonant cluster.

strong => ongstray

This is not a comparison…

1 Like

ok thanks, just seen that! need to do a rework then!

sorry, not sure what you mean here? can you explain more please? I can’t use the vertical slashes?

you can, but not like that. First, = is the assignment operator, second, if you use || you need to write a complete independent expression on both sides

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.