From the course: Learning the JavaScript Language
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Conditionals: If - JavaScript Tutorial
From the course: Learning the JavaScript Language
Conditionals: If
- [Instructor] A control structure in programming is a way to modify the flow of execution. Making decisions like whether to execute a portion of code at all or how many times to execute it. In this video, we're going to look at one of the fundamental control structures, the if statement. With an if statement, you can create forks in the logical road that your code will follow depending on certain conditions. This is also called branching. What we're going to do first is assign a variable based on a prompt for input from the user. To run these examples, we're going to open a new browser tab and open a JavaScript console. I'm using Chrome and I have a new tab here just on the about blank page. And then in the Developer menu, I'm going to open the JavaScript console. I have it set over here on the right and I've made it nice and large. This code is web specific. Since prompting the user for input is a little more…