Decisions with If/Else Statements

Decisions with If/Else Statements

7th Grade · Computer Science · 50 min

Lesson Preview

Learning Objective

I can write code using "if/else" statements to make decisions in JavaScript.

  • 1

    An `if` statement in JavaScript starts with the keyword if, followed by a comparison in parentheses, and code to execute in curly brackets.

  • 2

    If the condition in an `if` statement is not true, an else statement can be used to execute alternative code.

  • 3

    The `else if` statement lets you check multiple conditions in a sequence, executing the code block for the first condition that evaluates to true.