Returning Boolean Values from Functions

see the code below

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

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

This how i fixed it

function isLess(a, b) {
// Fix this code
if (a ===b) {
return true;
} else {
return false;
}
}

// Change these values to test
isLess(10, 15);
the question now is i should not use any if or else statements

I know that but the question to fix is nit to use the if statement. i don’t understand what you are trying to explain to me

its the most simple answers that always stump me… i try to make it harder on myself lol

function isLess(a, b) {
// Fix this code
return a < b;

}

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

thank you so much i was having a very hard time with it too

@robelte Getting the answer from the forums is easy, but do you know why? It’s

return a < b;

Yeah…Killing hours on this…

I put that answer in there and got it right, but I thought I was taking a shortcut by not using ===.

If “return a < b;” is correct I feel the question is misleading. Why go on about comparisons and have a link to the earlier question: “Comparison with the Equality Operator”?

(Edit: Raised a GitHub issue)

1 Like

I was trying to use the switch function, but switch (a < b) doesn’t work. Indeed this is a much more simple answer, just wish I would have found out by myself!

yup. this is me as well!

Answer =
function isLess(a, b) {
// Fix this code

return a < b;

}

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

solution:
function isLess(a, b) {
// Only change code below this line
return a<b;
{

return false;

}
// Only change code above this line

}
isLess(10, 15);