Conditionals & Logic Cheatsheet - Codecademy
Conditionals & Logic Cheatsheet - Codecademy
if
if Statement
else
else Clause
Relational Operators
switch
switch Statement
Logical operators can be used to combine two if (coffee > 0 && donut > 1) {
different conditions.
// Code runs if both are true
&& requires both to be true ( and )
|| requires either to be true ( or ) }
! negates the result ( not )
if (coffee > 0 || donut > 1) {
// Code runs if either is true
}
if (!tired) {
// Code runs if tired is false
}
Print Share