true
, only one expression evaluates to true
, or both expressions evaluate to false
.It’s done when the message “True β
True β
” is logged when both expression1
and expression2
are true.
It’s done when the message “True β
False β” is logged when expression1
is true.
It’s done when the message “False β True β
” is logged when expression2
is true.
It’s done when the message “False β False β” is logged when both expression1
and expression2
are false.
Before you start writing your algorithm, do you have a plan documented in plain language that describes how you will use JavaScript to get it done?
If you have completed this activity, further your knowledge by answering this question:
Use Google or another search engine to research this.
// Change the values and operators below to test your algorithm meets all conditions
var x = 50;
var expression1 = (x < 25);
var expression2 = (x > 50);
// Write Your JavaScript Code Here
//...
// Change the values and operators below to test your algorithm meets all conditions
var x = 50;
var expression1 = (x < 25);
var expression2 = (x > 50);
// Write Your JavaScript Code Here
// Check if both expressions are true using &&
if(expression1 && expression2) {
console.log("True β
True β
");
// If both conditions are not true, check if expression1 is true
} else if (expression1) {
console.log("True β
False β");
// If expression1 is not true, then check if expression2 is true
} else if (expression2) {
console.log("False β True β
");
// If none of the conditions above evaluate to true, both expressions must be false
} else {
console.log("False β False β");
}