Skip to main content
🌱 Coding Level 1: First Steps 🌱

Making Choices πŸ”€

Real programs make decisions. We use if and else:

If something is true, do this. Else (otherwise), do that.

function weather(rainy) {
  if (rainy) {
    return "umbrella β˜”";
  } else {
    return "sunglasses 😎";
  }
}

If rainy is true, it returns the umbrella. Otherwise, it returns the sunglasses. Read it carefully, then answer below. πŸ‘‡

What does weather(true) hand back?

What does weather(false) hand back?

if / else lets the computer: