- Arithmetic operators:
+,-,*,/,%(remainder),**(power). - Order of operations: parentheses, then
**, then* / %, then+ -. When in doubt, use parentheses. number % 2 === 0checks if a number is even.- Shortcuts:
x += 5meansx = x + 5.x++adds one,x--subtracts one. - Comparison operators (
>,<,>=,<=,===,!==) give backtrueorfalse. - Strings compare alphabetically, but uppercase comes before lowercase, and numbers in strings compare as text.
- Always use
===and!==, never the loose==and!=. - Logical operators:
&&(both true),||(at least one true),!(flip). - The
Mathobject has tools likeround,floor,ceil,max,min,abs,sqrt, andrandom. - Random whole number from 1 to max:
Math.floor(Math.random() * max) + 1.
Reading is step one
CurlyScript turns these notes into a game: short questions, an explanation after every answer, and a test at the end of each grade. Free, with nothing to sign up for.