View on GitHub

reading-note

Read: 05 - Operators and Loops

Operators and Loops

Looking at a flowchart , the code can take more than one path, which means the browser runs different code in different situations. In this chapter, you will learn how to create and control the flow of data in your scripts to handle different situations

Scripts often need to behave differently depending upon how the user interacts with the web page and/or the browser window itself. To determine which path to take, programmers often rely upon the following three concepts:

EVALUATION OF A CONDITION

#### In order to make a decision, your code checks the current status of the script. This is commonly done by comparing two values using a comparison operator which returns a value of true or false.

CONDITIONAL STATEMENTS

A conditional statement is based on a concept of if/then/else: if a condition is met, then your code executes one or more statements, else your code does something different (or just skips the step)

COMPARISON OPERATORS: EVALUATING CONDITIONS

You can evaluate a situation by comparing one value in the script to what you expect it might be. The result will be a Boolean: true or false.

See the picture to get to know it and know the name of each one and its function with examples

comp

if else statment

Here you can see that an if…else statement allows you to provide two sets of code:

if