Where define functions? In the global space, the mystery realm between functions. var mx; function init(){ ////////// // state variables ///////// var myBankAccount = 1000000; /soemthing somethign gameloop } function timeTravelCode(){ var dollars = 100; if(mx < w/2) } function paint(){ alert(dollars) if(mx > w/2) alert("no time!"); getRich = timeTravelCode(); } How do we make them? function nameO(parameters){ } example : function aceTest(name, mark){ } aceTest("Guzy", 75); function everybodyWins(){ marks[i] = 100; } alert(everybodyWins()) function verb(){ var list = []; list.push("out window!"); list.push("jump"); list.push("run"); list.push("make-a-function"); return list[Math.floor(Math.random()*list.length)] } alert("win"); alert(verb()); function randNumber(howBig, negatives){ var result = 0; while(result != 7) result = MAth.floor(MAth.random()* howBig); if(negatives == true){ result *= -1; }else{ result = result; } return result; while(true){ if() return "the bets ever" } } var tricky = false alert(randNumber(10, tricky)); ctx.fillText(randNumber(50, false), 100,100); var ballx = [] bally ballspx ballspy=[] init(){ for(var i=0; i < 150; i++){ addBall(rand(1000000000), rand(h), randnumber(10,false), randNumber(10, true)); } } function addBall(x,y, sx, sy){ if(sx < 1000000 && sy < 1000000){ ballx.push(x)' bally.push(y) ballspx.push(sx) ballspy.push(sy); } }