Until now, you have written programs that execute every line from top to bottom, without ever making a choice.
But real applications constantly need to make decisions.
Show a welcome message only if a user is logged in.
Allow a purchase only if the account balance is sufficient.
Display an error only if a form field is empty.
This ability to decide is provided by conditional statements.
In this chapter, you will learn how JavaScript makes decisions using the if-slash-else structure, and the comparison operators that produce the true or false values these decisions rely on.
Read the full transcript.
Create an account to read the whole episode, search across every transcript, and follow the shows you care about.
Until now, you have written programs that execute every line from top to bottom, without ever making a choice.
But real applications constantly need to make decisions.
Show a welcome message only if a user is logged in.
Allow a purchase only if the account balance is sufficient.
Display an error only if a form field is empty.
This ability to decide is provided by conditional statements.
In this chapter, you will learn how JavaScript makes decisions using the if-slash-else structure, and the comparison operators that produce the true or false values these decisions rely on.