# Pig Latin - Help me make my code work

**URL:** <https://forum.freecodecamp.org/t/pig-latin-help-me-make-my-code-work/166494>\
**Category:** General\
**Created:** [January 2, 2018, 11:01pm UTC](https://forum.freecodecamp.org/t/pig-latin-help-me-make-my-code-work/166494 "2018-01-02T23:01:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pierremg](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@pierremg](https://forum.freecodecamp.org/u/pierremg)\
**Post date:** [January 2, 2018, 11:01pm UTC](https://forum.freecodecamp.org/t/pig-latin-help-me-make-my-code-work/166494/1 "2018-01-02T23:01:15Z")

</div>

I know this is a poor code but this is what I could come up with. This code passed all tests except the third one (“glove”). Please, don’t provide me a totally different code or an easier one, help me to change my current code.

```auto
function translatePigLatin(str) {
  var str1 = str;
  var str2 = str1.charAt(0);
  var str2_1 = str1.charAt(1);
  if (str2 == 'a' || str2 == 'e' || str2 == 'i' || str2 == 'o' || str2 == 'u') {
    var str3 = str;
    var str4 = str3.split('');
    var str5 = str4.push('way');
    var str6 = str4.join('');
    return str6;
  } else if (str2 !== 'a' || str2 !== 'e' || str2 !== 'i' || str2 !== 'o' || str2 !== 'u') {
    var str7 = str1.split('');
    var str8 = str7.push(str2, 'ay');
    var str9 = str7.splice(0,1);
    var str10 = str7.join('');
    return str10;
  } else if (str2 && str2_1 !== 'a' || str2 && str2_1 !== 'e' || str2 && str2_1 !== 'i' || str2 && str2_1 !== 'o' || str2 && str2_1 !== 'u') {
    var str11 = str;
    var str12 = str1.split('');
    var str13 = str12.push(str2, str2_1, 'ay');
    var str14 = str12.join(''); 
    return str14;
  }
}
translatePigLatin("consonant");

```

**Link to the challenge:**  
[https://www.freecodecamp.org/challenges/pig-latin](https://www.freecodecamp.org/challenges/pig-latin)

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:31pm UTC](https://forum.freecodecamp.org/t/pig-latin-help-me-make-my-code-work/166494/4 "2021-01-17T20:31:54Z")

</div>


