How to execute the if statement only when both the inputs are different not when both inputs are same.
suppose:
var a=prompt("have Input","");
var b=prompt("have Input","");
if(a && !b){alert("ok")}
else{"wrong"}
the above condition works when both the inputs are true ,when both the inputs are false and when a is true and b is false but if a is false and b is true the if statement dont get executed .How to solve this issue through if statement.What is the way to get my problem solved?
It sounds like you are looking for a logical exclusive-or (XOR) operation. There are some Javascript examples here. My favorite (for being unexpected and simple) is:
Admittedly, this is a little unusual coding, and verges on being “too clever”. Sometimes if a language does not have direct syntax for an operation the code just has to be verbose, like getting the quotient and remainder from a division operation.