Conditional Statements
Goal of this lesson: explore how programs make decisions by evaluating conditions and introduce logic into code and covering the following concepts:
if
,else if
, andelse
statements.- comparison operators.
- logical operators.
- truthy vs falsy values.
- ternary operators.
- the
switch
statement.
EX:
if (mood === 'sleepy' && tirednessLevel > 8) {
console.log('time to sleep');
} else {
console.log('not bed time yet');
}
- -Evaluate to
false
when checked as a condition? The list of falsy values includes: 0
- Empty strings like
""
or''
null
which represent when there is no value at allundefined
which represent when a declared variable lacks a valueNaN
, or Not a Number- True will be numbers
- A short-circuit evaluation to assign a value to
writingUtensil
EX: ${writingUtensil}
||
or statements check the left-hand condition first
What did I learn today?
What I'll be doing tomorrow?
I will be learning about functions in JavaScript.
No comments:
Post a Comment