Quick JS Operator review
| Operator |
Meaning |
| = |
sets the left hand variable equal to the right hand expression |
| == |
tests whether the two sides of the the expression are equal |
=== |
tests whether they are both the same value and the same type (generally we won’t worry about this) |
| != |
tests whether the two sides are not equal |
| >,<,>=,<= |
exactly what you expect |
| += |
adds the right-hand expression to the left-hand variable |
Asa bonus here are a couple of string tricks:
| “\n” |
prints a carriage return/new line |
| “\”” |
prints a quotation mark directly |
| “someletters”.repeat(4) |
This is a built-in method of every string – it allows you to repeat the string easily without some kind of for loop (sorry guys! Didn’t think of this initially!). prints “someletterssomeletterssomeletterssomeletters” |
Loops