# How to solve this (solved)

**URL:** <https://forum.freecodecamp.org/t/how-to-solve-this-solved/57465>\
**Category:** General\
**Created:** [November 20, 2016, 9:29pm UTC](https://forum.freecodecamp.org/t/how-to-solve-this-solved/57465 "2016-11-20T21:29:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fisnikp](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/fisnikp/32/23812_2.png) [@fisnikp](https://forum.freecodecamp.org/u/fisnikp)\
**Post date:** [November 20, 2016, 9:29pm UTC](https://forum.freecodecamp.org/t/how-to-solve-this-solved/57465/1 "2016-11-20T21:29:57Z")

</div>

Questions is to use Switch instead of If/else statments:  
**function isLess(a, b) {**  
\*\* // Fix this code\*\*  
\*\* if (a \< b) {\*\*  
\*\* return true;\*\*  
\*\* } else {\*\*  
\*\* return false;\*\*  
\*\* }\*\*  
**}**

**// Change these values to test**  
**isLess(10, 15);**

i tried this, What is wrong here:

 ![](https://global.discourse-cdn.com/freecodecamp/original/3X/b/3/b3a56de996a47d63ed0f0c2e783f62e7e12bb16f.png)

---

<div class="post-metadata">

**Author:** ![jamesperrin](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jamesperrin/32/158725_2.png) [@jamesperrin](https://forum.freecodecamp.org/u/jamesperrin)\
**Post date:** [November 20, 2016, 9:33pm UTC](https://forum.freecodecamp.org/t/how-to-solve-this-solved/57465/2 "2016-11-20T21:33:31Z")

</div>

@fisnikp Here is the Free Code Camp information about JS Switch statement.

> **[JavaScript Switch Statements Explained With Examples](https://forum.freecodecamp.org/t/javascript-switch/16383)**
>
> Switch Statements A switch statement in programming is similar to an if-else statement, but has the benefit of sometimes being easier to read when there are a lot of conditions. Also it allows a default block to be added that will be executed...

---

<div class="post-metadata">

**Author:** ![fisnikp](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/fisnikp/32/23812_2.png) [@fisnikp](https://forum.freecodecamp.org/u/fisnikp)\
**Post date:** [November 20, 2016, 9:37pm UTC](https://forum.freecodecamp.org/t/how-to-solve-this-solved/57465/3 "2016-11-20T21:37:10Z")

</div>

i am not understanding this very well can you explain it by solving my example

---

<div class="post-metadata">

**Author:** ![Ukuthula](https://avatars.discourse-cdn.com/v4/letter/u/bcef8e/32.png) [@Ukuthula](https://forum.freecodecamp.org/u/Ukuthula)\
**Post date:** [November 20, 2016, 9:51pm UTC](https://forum.freecodecamp.org/t/how-to-solve-this-solved/57465/6 "2016-11-20T21:51:14Z")

</div>

The switch statement can only test ONE variable for a certain value.  
For example an integer for the values 1, 2 ,3, etc.  
I would suggest using a boolean variable, true for less and false for equal or more.

`switch(a<b){ case true: return true; break; default: return false;`

---

<div class="post-metadata">

**Author:** ![fisnikp](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/fisnikp/32/23812_2.png) [@fisnikp](https://forum.freecodecamp.org/u/fisnikp)\
**Post date:** [November 20, 2016, 9:57pm UTC](https://forum.freecodecamp.org/t/how-to-solve-this-solved/57465/7 "2016-11-20T21:57:23Z")

</div>

Here is Solution:

function isLess(a, b) {  
// Fix this code  
return a \< b;  
}  
// Change these values to test  
isLess(10, 15);

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [January 16, 2021, 6:09am UTC](https://forum.freecodecamp.org/t/how-to-solve-this-solved/57465/8 "2021-01-16T06:09:39Z")

</div>

Closed on January 16, 2021, 6:09am UTC


