Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Javascript: How can I chain conditionals?

Can you help me with this?

x = 2 + 2;
y = 1 + 3;

a = 5 + 5;
b = 7 + 3;

///How can I do this: 
if (x == 4 && y == 4 and a == 10 && b == 10) {
  console.log("you are correct!");
}

///Instead of this: 
if (x == 4 && y == 4) {
  console.log("you are correct!");
}

if (a == 10 && y == 10) {
  console.log("you are correct!");
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Do it like this

if((x == 4 && y == 4) || (a == 10 && b == 10)){
    console.log("you are correct!")
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading