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 - JavaScript Tutorial
From the course: Coding for Visual Learners: Learning JavaScript from Scratch
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.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.