Week5day1 Intro to Operators and ControlFlow

Operators are the building blocks that enable you to perform operations on variables, such as arithmetic calculations or logical comparisons. Control flow, on the other hand, governs the order in which your code is executed. Conditionals, like 'if' statements, allow you to make decisions based on specific conditions, steering your program in different directions. Meanwhile, loops, such as 'for' and 'while,' empower you to repeat actions efficiently.

Closures and Scope

Together, these concepts build a robust experience for users & propel your ability to create interactive and intelligent applications. if (condition) { / code to run if condition is true / } else { / run some other code instead / }

let shoppingDone = false; let childsAllowance;

if (shoppingDone === true) { childsAllowance = 10; } else { childsAllowance = 5; }

const x = 1 + 2 * 3; const y = 2 * 3 + 1;

Name Shorthand operator Meaning Assignment x = f() x = f() Addition assignment x += f() x = x + f() Subtraction assignment x -= f() x = x - f() Multiplication assignment x = f() x = x * f() Division assignment x /= f() x = x / f() Remainder assignment x %= f() x = x % f() Exponentiation assignment x *= f() x = x ** f() Left shift assignment x <<= f() x = x << f() Right shift assignment x >>= f() x = x >> f() Unsigned right shift assignment x >>>= f() x = x >>> f() Bitwise AND assignment x &= f() x = x & f() Bitwise XOR assignment x ^= f() x = x ^ f() Bitwise OR assignment x |= f() x = x | f() Logical AND assignment x &&= f() x && (x = f()) Logical OR assignment x ||= f() x || (x = f()) Nullish coalescing assignment x ??= f() x ?? (x = f())