read 05

1- Comparison and Logical operators

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

Keep in mind that you must use “==”, not “=”, when testing if two primitive values are equal.

- Logical operators

Logical operators allow you to compare the results of more than one comparison operator.

2- LOOPS

Loops are used in JavaScript to perform repeated tasks based on a condition. Conditions typically return true or false when analysed. A loop will continue running until the defined condition returns false.

The three most common types of loops are:

1- For

If you need to run code a speciific number of times , use a for loop. in a for loop , the condition is usually a counter which is used to tell how many times the loop should run INITIALIZATION , CONDITION, UPDATE

for loop explain:

2- while

If you do not know how many times the code should run , you can use a while loop. Here the condition can be something other than counter, and the code will continue to loop foras long as the condition is true using while loops while loop explain

3- do while

The do…while loop is very similar to the while loop, but hasone key difference: itwill always run the statements inside the curly braces at least once, even if the condition evaluates to false.

do while loop explain

Learn more about loops