by PDX Code Guild - Sept. 22, 2015
Quick Notes: Javascript Syntax

Quick Notes are designed to be a helpful reference for someone who has already learned about a topic conceptually but has not yet memorized the material.

Javascript Variable var name = x * y;

Variable Example var doughnuts = flavors * baked ;

Function function name(parameters){ return parameters * 2; }

Function Example function bake(doughnuts){ return doughnuts * 2; }

Conditional Statements if (condition) { code to be executed if true; } else if (condition 2){ code to be executed if condition2 is true; } else { code to be executed if both conditions false; }

Conditional Statement Example if (doughnuts < 20) { bake more doughnuts; }else if (doughnuts > 100){ eat more doughnuts; } else { take a nap; } For Loops for (starting condition; condition for loop to run; the counter){ code to be executed } For Loop Example for (i=0; i<20 ; i+){ bake more doughnuts; }