# Need Help with If Else Statement

**URL:** <https://forum.freecodecamp.org/t/need-help-with-if-else-statement/161722>\
**Category:** General\
**Created:** [December 1, 2017, 5:02am UTC](https://forum.freecodecamp.org/t/need-help-with-if-else-statement/161722 "2017-12-01T05:02:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdavidson3](https://avatars.discourse-cdn.com/v4/letter/r/96bed5/32.png) [@rdavidson3](https://forum.freecodecamp.org/u/rdavidson3)\
**Post date:** [December 1, 2017, 5:02am UTC](https://forum.freecodecamp.org/t/need-help-with-if-else-statement/161722/1 "2017-12-01T05:02:57Z")

</div>

```javascript
function orderMyLogic(val) {
 
  if (val < 5) {
    return "Less than 5";
  }
    
  else if (val < 10) {
    return "Less than 10";
  } 
  
  else {
    return "Greater than or equal to 10";
  }

}

// Change this value to test
orderMyLogic(7);

```

  

I’ve run my above code and it kept coming back as "orderMyLogic(11) should return “Greater than or equal to 10"” However; I tried multiple combos of the code many times only to reset the code because nothing was working. I returned the same code above and then it worked.

What I am not understanding is why the code still ran the final else statement if 7 is less than 10?

---

<div class="post-metadata">

**Author:** ![IsaacAbrahamson](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/isaacabrahamson/32/30882_2.png) [@IsaacAbrahamson](https://forum.freecodecamp.org/u/IsaacAbrahamson)\
**Post date:** [December 1, 2017, 5:35am UTC](https://forum.freecodecamp.org/t/need-help-with-if-else-statement/161722/2 "2017-12-01T05:35:40Z")

</div>

Hello, I made some edits to your post as a moderator. You originally posted your question in a thread that had been inactive for several months. I moved your question to a new topic so you can get help better.

I’ve also edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See [this post](http://forum.freecodecamp.com/t/forum-code-formatting/25574) to find the backtick on your keyboard. The “preformatted text” tool in the editor (`</>`) will also add backticks around text.

![markdown_Forums](https://sea3.discourse-cdn.com/freecodecamp/uploads/default/original/3X/4/b/4b9a26f0c243380dd84935f4e29b92e3ecee8d05.gif)

---

<div class="post-metadata">

**Author:** ![IsaacAbrahamson](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/isaacabrahamson/32/30882_2.png) [@IsaacAbrahamson](https://forum.freecodecamp.org/u/IsaacAbrahamson)\
**Post date:** [December 1, 2017, 5:39am UTC](https://forum.freecodecamp.org/t/need-help-with-if-else-statement/161722/3 "2017-12-01T05:39:34Z")

</div>

I am not sure what your problem is. I ran your code and it gave me less than 10. If you are having trouble with a specific freeCodeCamp challenge, could you link to it? Thanks!

https://repl.it/repls/SpectacularBustlingFennecfox?lite=true

---

<div class="post-metadata">

**Author:** ![longhour](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/longhour/32/71713_2.png) [@longhour](https://forum.freecodecamp.org/u/longhour)\
**Post date:** [December 1, 2017, 6:14am UTC](https://forum.freecodecamp.org/t/need-help-with-if-else-statement/161722/4 "2017-12-01T06:14:15Z")

</div>

your ccode seems good. i don’t see problem here.

---

<div class="post-metadata">

**Author:** ![r1chard5mith](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/r1chard5mith/32/160542_2.png) [@r1chard5mith](https://forum.freecodecamp.org/u/r1chard5mith)\
**Post date:** [December 1, 2017, 12:06pm UTC](https://forum.freecodecamp.org/t/need-help-with-if-else-statement/161722/5 "2017-12-01T12:06:05Z")

</div>

I think what you’re missing is that even though you only have `orderMyLogic(7);` as a call to the function in your own code, the FCC testing harness is calling it with a bunch of different values also, including `orderMyLogic(11)`. That test was apparently failing and is now passing.

---

<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:33pm UTC](https://forum.freecodecamp.org/t/need-help-with-if-else-statement/161722/6 "2021-01-17T20:33:15Z")

</div>

Closed on January 17, 2021, 8:33pm UTC


