Switch and if interchanging

Switch and if interchanging
0

#1
function isLess(a, b) {
  // Fix this code

    switch(a,b){
    case (a<b):
    return true;                    /*case (a<b) nto returning true*/
    break;
    
    default:
    return false;
  }
}
// Change these values to test
isLess(10, 15);

#2

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


#3

switch evaluates an expression, and the case statements are different possible results.

switch(a, b) is not valid. What you want inside of switch is the expression you are checking. If you want to check whether or not a is less than b, that would go inside of switch and each case would be the possible results and then what to do in those cases.