This is the first coding project ive ever done, and i cant figure out how to make a if statement with two conditions?
I think the project is attached ive never done this before
in order to use a if statment you need to use certain operators call Logical Operators.
The ones that you need are && and || && is the and logical operator, and || is the or logical operator.
&& compares 2 conditions, works if both are true || compares 2 conditions, and works if at least 1 is true
var x = 1 var y = 5 /* The following if statment will run, because at least 1 condition is true */ if ((x === 1) || (y != 5)){ }
However, if we replace || with &&
/* The following if statment not run, because at only 1 condition is true. Both have to be true in order to run */ if ((x === 1) && (y != 5)){ }
Thanks that fixed it
How do i have a if statement with multible conditions
This is the first coding project ive ever done, and i cant figure out how to make a if statement with two conditions?
I think the project is attached ive never done this before
in order to use a if statment you need to use certain operators call Logical Operators.
The ones that you need are && and ||
&& is the and logical operator, and || is the or logical operator.
&& compares 2 conditions, works if both are true
|| compares 2 conditions, and works if at least 1 is true
However, if we replace || with &&
Thanks that fixed it
@coreDumpedSeg