# Returning Boolean Values from Functions

## Problem Explanation

Instead of using an if/else block to compare variable we can do it right inside the return statement with a comparison operator and minmal code.

Fix the function `isLess` to remove the `if...else` statements.

``````// Fix this code
if (a < b) {
return true;
} else {
return false;
}
``````

## Hints

### Hint 1

As with the previous exercise you are about to change how the function returns the correct value, meaning you don’t have to reuse or modify that code but to substitute it.

### Hint 2

In order to return `true` or `false` you don’t need two statements nor use `if` ones. The correct comparison operator is all you need.

## Solutions

Solution 1 (Click to Show/Hide)
``````function isLess(a, b) {
// Fix this code
return a <= b;
}
// Change these values to test
isLess(10, 15);
``````

2 Likes

I really don’t understand this one! can someone help?

5 Likes

Watch what you have in Instructions. - create function less then
function isLess(a, b) {
// Fix this code
return a < b;

}
this would work

9 Likes

## Further explanation:

The purpose of `isLess()` is to determine whether a value is less than b value.
So if a is less than b, the answer should be TRUE. If not, you should receive a FALSE response in the console.

2 Likes

This worked for me.

function isLess(a, b) {
switch (true) {
case a < b:
break;
case a > b:
break;
}
}

4 Likes

it works for me.

``````function isLess(a, b) {
// Fix this code
return a*3 === b*2;
}

// Change these values to test
isLess(10, 15);
``````
6 Likes

why so long, just:

function isLess(a,b) {
return a < b;
}

working fine

15 Likes