JavaScript: Working with Conditional Code in JavaScript


show more Find out how to create a simple if statement in JavaScript and work with conditional code, which allows you to ask questions and create code that only runs when certain conditions are met. show less
please wait ...

Working with conditional code

Beyond the most basic JavaScript one-liners, we need to start asking questions, being able to have code that only runs under certain conditions rather than all the time, and we begin this with the classic if statement, found in any programming language, written in JavaScript, as in other C-based languages, using this format. We have the word if, and then we have a condition inside parentheses and then if that condition is true, we will execute whatever code is inside the braces here. Now a quick aside for the folks new to programming.

Yes, in programming languages we are really picky about the symbols we use and about what we call them. So just to be very specific, when I say parentheses, I mean these; when I say brackets and I usually say square brackets, I mean these guys; and when I say braces, and I'll usually say curly braces, I mean these. Now, they serve similar purposes, to mark where something starts and where it finishes, but they are not interchangeable. Now all of these ar...

Working with conditional code
Video duration: 5m 44s 5h 31m Beginner

Viewers:

Find out how to create a simple if statement in JavaScript and work with conditional code, which allows you to ask questions and create code that only runs when certain conditions are met.

Subjects:
Developer Web
Software:
JavaScript
Author:
please wait ...