title: switch statement always goes to default in javascript
body: <p>I want to do a simple program that prints out different phrases depending on whether a specific condition is met. We input 2 integer parameters in a function and it evaluates whether one number is greater, less than, or whether both numbers are equal to each other. My code looks like this:</p>
  
  <pre><code>function CheckNums(num1,num2) {
  switch (num1,num2) {
    case (num2&gt;num1):
     console.log('num2 greater than num1');
     break;
    case (num2 === num1):
     console.log('both equal');
     break;
    default:
     console.log('num1 greater than num2');
    }
  }
  </code></pre>
  
  <p>Either case, whether I input: CheckNums(4,5) , CheckNums(2,2) , CheckNums(5,4) the program runs default.</p>
  
  <p><strong>IMPORTANT:</strong> Im not asking for an alternative solution to this problem. I already managed to solve it using if statements or the ternary operator. What I'm asking is: <em>WHY IS THIS SWITCH NOT WORKING?</em></p>
  
  <p><strong>Questions that I`ve consulted that didn't solve my problem:</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/28267645/javascript-switch-statement-only-executes-the-default-case?rq=1">JavaScript switch statement only executes the default case</a></p>
  
  <p>The sol:This guy had a problem where the Math.random() generator only generated numbers with decimal places, which of course, wouldn't go to either case except default.</p>
  
  <p><a href="https://stackoverflow.com/questions/10848036/js-switch-case-not-working-correctly-always-default-is-executed">JS Switch case not working correctly always default is executed</a></p>
  
  <p>The sol:This guy was inputing strings as a parameter, and was expecting int values in the cases.</p>
  
  <p><strong>Other notes:</strong></p>
  
  <p>-Maybe the answer lies on using parseint? (Assuming that the parameters are not being inputed as ints.)</p>
  
  <p>-I removed the parenthesis that go in the cases. That didn't solve my problem.</p>
  
  <p>-For the second case, I also experimented using equality operator(==) instead of the Identity operator (===). The second case still did not work.</p>
  
  <p><strong>My best guess for where the problem is hiding:</strong>
  When I compiled the program in google chrome console, I get the following notification: "undefined". So, I think that's whats not allowing my cases to evaluate the parameters properly. Something is not being defined properly.</p>