Ict Q3
Ict Q3
1) Add: +
2) Subtract: -
3) Multiply: * Methods
4) Divide: / - Actions that we can perform.
5) Remainder (Modulo): % - Data types have access to specific
6) Dot: . methods that allow us to handle instances
of that data type.
String Concatenation
Built-in Objects
Concatenation - Automatically within the language library
- The process of appending one string to Console.log(Math.random()); – Prints a
another random number between 0 and 1.
- Will join the strings exactly, so we need to
make sure to include the space. To generate a random number bethween 0
and 50:
Just like regular math, we can combine, or
chain our operations to get a final result. Math.random() * 50
Math.floor(Math.random() * 50);
Things you can do with variables:
Let
- Introduced in ES6
- Signals that the variable can be reassigned
a different value
- Block style
Increment Operator
When declaring a variable without assigned
the variable a value, it will be undefined. - Denoted by ++
- Will increase the value of the variable by 1.
Const
Decrement Operator
- Introduced in ES6
- Short for constant - Denoted by –
- You can store any value within const - Will decrease the value of the variable by 1.
- Cannot be reassigned because it is
constant.
- If you try to declare a const variable
without a value, you’ll get a SyntaxError
- Universal scale
Comparison Operators
Conditional Statements
- When writing conditional statements, we
- Checks a specific condition(s) and performs
need to use different types of operators to
a task based on the condition(s)
compare values
- If-else decisions
Less than <
Concepts
Greater than >
1) If, else if, and else statements
2) Comparison operators Less than or equal to <=
3) Logical operators
Greater than or equal to >=
4) Truthy vs falsy values
Is equal to === The not operator will take a true value and
return a false value.
Is not equal to !==
Logical operators are often used in
- Compares the value on the left with the
conditional statements to add another layer
value on the right
of logic to our code.
Logical Operators
Truthy and Falsy
- Operators that work with boolean values
- Checks if a variable exists, not necessarily
known as logical operators.
equating to a specific value, only if it has a
- Used to add more sophisticated logic to our
value.
conditionals.
1) 0
2) Empty strings ‘’ or “”
3) Null which represents that there is no
value at all
4) Undefined which represents when a
declared variable lacks a variable
The or operator only cares if one condition is 5) NaN or Not a Number
true, then it will execute the if. If both are
If it is not in the list of falsy values, it is
false, then the else will execute.
automatically truthy.
Else If Statements
Ternary Operator
- Read from top to bottom, so the first
- Used to simplify an if…else statement
condition that evaluates to true from top to
- Short-hand syntax
bottom is the block that gets executed
Switch Keyword