How to solve this (solved)

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:

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

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

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;

1 Like

Here is Solution:

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

1 Like