Jump to content

JavaScript if Else and question


Recommended Posts

Hi

if I have 2 conditions A and B but I want to make and IF Else And, how is the syntax then.

If only A is filled then do...

If only B is filles then do...

If both A and B is filles then do...

How Will this syntax looks like ?

 

 

 

 

 

Link to post
Share on other sites

If only A is filled, it means that B has to not be filled.

The structure would like similar to the following, assuming A and B are booleans:

if(A && !B) {
  // Only A
} else if(B && !A) {
  // Only B
} else if(A && B) {
  // Both A and B
}

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...