curriculum/challenges/english/blocks/basic-javascript/5679ceb97cbaa8c51670a16b.md
You may recall from <a href="/learn/javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator" target="_blank" rel="noopener noreferrer nofollow">Comparison with the Equality Operator</a> that all comparison operators return a boolean true or false value.
Sometimes people use an if/else statement to do a comparison, like this:
function isEqual(a, b) {
if (a === b) {
return true;
} else {
return false;
}
}
But there's a better way to do this. Since === returns true or false, we can return the result of the comparison:
function isEqual(a, b) {
return a === b;
}
Fix the function isLess to remove the if/else statements.
isLess(10, 15) should return true
assert(isLess(10, 15) === true);
isLess(15, 10) should return false
assert(isLess(15, 10) === false);
You should not use any if or else statements
assert(!/if|else/g.test(__helpers.removeJSComments(code)));
function isLess(a, b) {
// Only change code below this line
if (a < b) {
return true;
} else {
return false;
}
// Only change code above this line
}
isLess(10, 15);
function isLess(a, b) {
return a < b;
}