0
    <script>
      c3=multi(8,7);
   function multi(a ,b){
       if(a>b){
           console.log("a is greater than b")
       }
       else if(a=b){
           console.log("a is equal to b")
       }
       else{
           console.log("a is small ")
       }
   }
  
  
   console.log(c3);

I don't know why but the third condition is not working . mutli(a,b) is the function

  • I've accidentally used a Java dupetarget rather than JavaScript (which I'll fix), but this is something that Java and JavaScript have in common. `=` is always **assignment**, not comparison. Use `==` or `===` in your `else if`. – T.J. Crowder Feb 18 '21 at 10:58
  • @T.J.Crowder fixed the dupe target – VLAZ Feb 18 '21 at 10:59
  • its 17 not 7 in the function – Uttkarsh ' s world m Feb 18 '21 at 11:00
  • Thanks @VLAZ. I thought we had one with a better question, but the answer there is good, so... – T.J. Crowder Feb 18 '21 at 11:01
  • 1
    @T.J.Crowder thx it worked for me – Uttkarsh ' s world m Feb 18 '21 at 11:01
  • @T.J.Crowder I also think I've seen one that's more on point but I can't remember where and how to find it. This one serves its purpose, I think and it's [in the canonical](https://stackoverflow.com/questions/9549780/what-does-this-symbol-mean-in-javascript), so it's easy to find, at least. – VLAZ Feb 18 '21 at 11:02
  • Just a minor note: It's possible that you'll get `a is small` even when `a < b` is not true. That happens if either `a` or `b` is `NaN`, because all comparison operators result in `false` when `NaN` is either of their operands. (Even `NaN === NaN` is false.) – T.J. Crowder Feb 18 '21 at 11:03

0 Answers0