0

I am just performing simple Logical AND Operation inside Script mediator of WSO2 EI 6.6.0

Code:

 <script language="js"><![CDATA[
 var log = mc.getServiceLog();   
var initial_group="L1";
var initial_queue ="";
 if( (initial_group =="L1") && (initial_queue ="WIN")){
     log.info("Matching success!");}
     else{
         log.info("Matching failed!");
     }
     ]]></script>

Even though i passed initial_queue as empty, && condition of if statement is matched and finally it produce output like below

Matching success!

Instead of Matching failed!

Can anyone explain this strange behavior of Logical && Operator?

Community
  • 1
  • 1
Justin
  • 855
  • 2
  • 11
  • 30
  • 1
    It's probably a typo, you want `==` or `===` in `initial_queue ="WIN"`. In JavaScript, `=` is always **assignment**. For equality, use `==` or `===`. – T.J. Crowder Jan 27 '22 at 10:48
  • Hi @T.J.Crowder Thanks for your quick response. as you said it is typo. after replacing "=" as "==" works fine. – Justin Jan 27 '22 at 10:57

0 Answers0