JavaScript: Conditions

1var color = "red"
2
3if (color == "green") {
4  console.log("This is my favorite color!")
5}
6
7console.log(color)

What happens when we change color to "green"?

1var age = 25
2
3if (age < 18) {
4  console.log("Minor")
5} else {
6  console.log("Adult")
7}

What happens when we change age to 15?

1var name = "John"
2
3if (name == "John") {
4  console.log("Welcome home, Mr. Doe")
5} else if (name == "Jane") {
6  console.log("Welcome home, Mrs. Doe")
7} else {
8  console.log("Welcome, Guest")
9}

What happens when we change name to "Chad"?

We frequently need to apply conditions to the behavior of our programs, so they can behave differently in different situations