Tuesday, April 16, 2019

JavaScript(3)---Conditional Statements

Conditional Statements

Goal of this lesson:  explore how programs make decisions by evaluating conditions and introduce logic into code and covering the following concepts:
  • ifelse if, and else 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 all
  • undefined which represent when a declared variable lacks a value
  • NaN, or Not a Number
  • True will be numbers
  1. 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