Functions function name( arguments/parameters ) Ex var result function doMathGood(num1, num2, name){ //alert 'name' did 'their' homework //function does the math and returns the value afterwards alert(name + " did great math. This is a lie."); return num1 + num2; } Usage: Call name, provide arguments/parameters (if needed) var result = doMathGood(50,60, "GMan"); alert(doMAthGood(80,90, "GMan")); Value generated by the function (via its return statement) isn't stored, thus is lost to the tron like world in your computer. To save it, try: answerToWorldHunger = doMathGood(50,60,"GMan"); Calling the function at all made the alert, using the equals (assignment statement) made the results that were RETURNed persist and not get lost. Functions can do jobs, return values, or both. Tiny detail: Methods Methods are basically functions except they are attached to objects (gr 12 stuff) ctx.fillRect <- fillRect is part of 'ctx', so its a method fillRect() on its own makes no sense, because theres no canvas being told to do anything Example worker.weld() makes sense, its the worker who welds weld() makes no sense, because it takes a worker to do welding work, the weld code alone can stand apart and be used like that. function beWacky() <- theres no '.' involved, it stands alone. So its okay to just beWacky() its not part of a bigger thing. var ballx = [] var bally = [] var bsx = [] var bsy = []; //individual function followMouse(index){ if(ballx[index] < mx) bsx[index] = 5; else bsx[index] = -5; if(bally[index] < my) bsy[index] = 5; else bsy[index] = -5; ballx[index] += bsx[index]; bally[index] += bsy[index]; } //NOT individual function followMouseEveryone(){ for(var index = 0; index < ballx.length; index++){ //Direction changes if(ballx[index] < mx) bsx[index] = 5; else bsx[index] = -5; if(bally[index] < my) bsy[index] = 5; else bsy[index] = -5; //Actual Motion ballx[index] += bsx[index]; bally[index] += bsy[index]; } } function paint(){ followMouseEveryone(); for(var i = 0; i < asteroids.length;i++){ ballCollision(i); //i is the index of a specific asteroid } } function ballCollision(index){ //collides asteroid[index] with every ball via a for loop } }