From the course: Coding for Visual Learners: Learning JavaScript from Scratch

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Conditionals

Conditionals

- [Instructor] So far all the programs we wrote execute in a top to bottom linear fashion, but it's quite common in programming to have some parts of the program to execute only if a certain condition is satisfied. For example, using the variable frame Count, we are now able to animate a shape across the screen. But what if I wanted this animation starts only after a certain frame, like after frame hundreds? This can be done using your programming structure called an if statement. The if statement allows us to execute a block of codes only if a certain condition is satisfied. How an if statement is written is that we start off with the declaration if, and inside the parenthesis next to it, we write an expression that should evaluate to true or false. Next, inside the curly brackets right after the if statements, we write a block of code that we would like to have executed if the expression that wrote evaluates to true.…

Contents