CodeOrbit

šŸ

Orbit Reached

You have completed all mission contexts.

Context 30 / 30

Readability is Key

You can chain 10 operators together on one line, but it makes the code unreadable. Break complex math into smaller variables so humans can understand it.

Context 29 / 30

Using Parentheses ()

You can force the computer to do math out of order by wrapping it in parentheses. (10 + 5) * 2 forces the addition first, giving 30.

Context 28 / 30

Operator Precedence

JS follows the order of operations (PEMDAS). 10 + 5 * 2 is 20, not 30, because multiplication happens before addition.

Context 27 / 30

Nullish Coalescing (??)

This operator checks if something is missing. 'let name = inputName ?? "Guest"'. It means: Use inputName, but if they gave me null or undefined, use 'Guest' instead.

Context 26 / 30

The Ternary Operator (?)

It’s a mini yes/no decision on one line. 'score > 50 ? "Pass" : "Fail"'. It means: If score > 50 is true, output Pass. Otherwise, output Fail.

Context 25 / 30

String Operators

You already know '+' glues strings. But comparison operators work on text too! 'A' < 'B' is true because A comes first in the alphabet.

Context 24 / 30

Short-Circuiting (||)

If JS sees an '||' and the first half is true, it skips the second half. It already found the one 'true' it needed to pass.

Context 23 / 30

Short-Circuiting (&&)

If JS sees a '&&' and the first half is false, it doesn't even bother reading the second half. It already knows the whole thing fails. It saves processing time.

Context 22 / 30

Logical NOT (!)

Putting an exclamation mark flips a boolean. If 'isRaining' is true, '!isRaining' becomes false. It is an instant reverse switch.

Context 21 / 30

Logical OR (||)

The '||' operator is lenient. 'hasCash || hasCreditCard' means as long as ONE of the sides is true, the whole statement is accepted as true.

Context 20 / 30

Logical AND (&&)

The '&&' operator forces multiple rules to be true. 'hasKey && isDoorUnlocked' means BOTH things must be true before you can enter.

Context 19 / 30

Strict Not Equal (!==)

Just like equality, use the strict version. '!==' ensures the two items are completely different in value or data type.

Context 18 / 30

Not Equal (!=)

The exclamation mark means 'NOT'. So '10 != 5' is asking 'Is 10 NOT equal to 5?'. The answer is true.

Context 17 / 30

Strict Equality (===)

Triple equals is what professionals use. It checks if the value AND the data type are identical. 5 === '5' is false. Always use triple equals.

Context 16 / 30

The Danger of Loose Equality (==)

Double equals checks if the values look similar, ignoring the data type. It thinks the number 5 and the string '5' are perfectly equal. This causes nasty bugs.

Context 15 / 30

Greater/Less or Equal (>=, <=)

Adding an equals sign checks if it is bigger OR exactly the same. '10 >= 10' is true, whereas '10 > 10' is false.

Context 14 / 30

Comparison: Less Than (<)

The alligator eats the bigger number. '10 < 5' returns false. You use these to check if a user is old enough or a score is high enough.

Context 13 / 30

Comparison: Greater Than (>)

Compares two sides. '10 > 5' returns the boolean true. It asks a yes/no question of the data.

Context 12 / 30

Compound Subtraction (-=)

Works exactly like addition. 'health -= 20' immediately removes 20 from the health variable. You can also do this with *= and /=.

Context 11 / 30

Compound Assignment (+=)

Instead of typing 'cash = cash + 50', you can just type 'cash += 50'. It is a faster way to update a variable based on its own current value.

Context 10 / 30

Decrement (--)

The opposite of increment. 'lives--' means 'subtract exactly 1 from the current lives'. Perfect for countdowns.

Context 9 / 30

Increment (++)

Typing 'score++' is a shortcut. It means 'take the current score, and add exactly 1 to it'. We use this constantly in games and loops.

Context 8 / 30

Exponentiation (**)

Double asterisk means 'to the power of'. 2 ** 3 means 2 * 2 * 2 (which is 8). It's a quick way to do heavy exponential math.

Context 7 / 30

The Modulo Operator (%)

This is the remainder tool. 10 % 3 asks: 'If I divide 10 by 3, what is left over?' The answer is 1. It is perfect for determining if numbers are odd or even.

Context 6 / 30

Arithmetic: Division (/)

Use the forward slash to divide. 10 / 2 gives 5. Remember, dividing by zero in JS doesn't crash the computer; it just returns the concept of 'Infinity'.

Context 5 / 30

Arithmetic: Multiplication (*)

Use the asterisk symbol for multiplication. 10 * 5 gives 50. Essential for calculating areas, scaling graphics, or determining total costs.

Context 4 / 30

Arithmetic: Subtraction (-)

Standard subtraction. 10 - 5 gives 5. Unlike addition, you cannot subtract strings. 'Hello' - 'World' will give you an error (NaN).

Context 3 / 30

Arithmetic: Addition (+)

Just like regular math. 10 + 5 gives 15. If used with strings, it glues them together. It's the most common tool in your kit.

Context 2 / 30

The Assignment Operator (=)

The equals sign doesn't mean 'these are equal'. It means 'take what is on the right, and put it into the box on the left'. It is a loading mechanism.

Context 1 / 30

What are Operators?

Operators are the verbs of programming. If variables are the nouns (the objects), operators tell those objects to do something—like combine, subtract, or compare.

← Abort Mission

Lecture 03: Operator in Javascript

Total Duration: 1 hrs 58 mins 56 secs

Initiate Launch Scroll UP to ignite thrusters