Here are some notes I've made to help you guys with your syntax. Think of it like a "cheatsheet". Some tips to remember:
- Keep an eye on semicolons, usually control flow blocks (
if
blocks,for, while
loops etc.) do not need a semicolon. - Keep an eye on your opening and closing brackets (
{ & }
). - Be careful when using assignment operators (
=
) and equality operators (== and ===
). Assignment is for setting, equality is for comparing. - Keep an eye on quotation marks. Match doubles with doubles (
"
), singles with singles ('
).- Also: Watch when you're using apostrophes inside strings:
var sentence = "You're weird";
.
Make sure you don't do this:var sentence = 'You're weird';
This will give you errors.
- Also: Watch when you're using apostrophes inside strings:
- When checking conditions with logical operators (
&&, ||, !
), you cannot combine your conditions. - Incorrect:
if ( chicken === yummy && tasty )