Expressions and Operators
This a summary of what I have learned during the class and by reading this tutorial.
Logical operators
We can use Logical operators to make the code more readble and to merge many IF statments in one function:
- && the AND operator.
Returns expr1 if it can be converted to false; otherwise, returns expr2. Thus, when used with Boolean values, && returns true if both operands are true; otherwise, returns false.
-
the OR operator >Returns expr1 if it can be converted to true; otherwise, returns expr2. Thus, when used with Boolean values, returns true if either operand is true; if both are false, returns false. - ! logical NOT
Returns false if its single operand that can be converted to true; otherwise, returns true.
LOOPS
Loops make it easier to repeat a function, for now, we will mention 2 types of loops. they are:
-
FOR loop we use when we want to perform a task for a known number of times
for ([initialExpression]; [conditionExpression]; [incrementExpression]) statement
-
WHILE loop we use this when we want to repeat the action for an unknown number of times
while (condition) statement
Get back to EMAM’S HOMEPAGE
I have created this page as a part of my project using Github, Please visit my profile, I will be more than happy to hear from you all. © Emam Shararah 2021