Variable: This is a “container” for whatever we assign it. We can assign numbers, words (known as “strings” in Javascript), lists, functions or other “objects” (yet to be discussed) to a variable. Some examples of this are below:
var x = 1; //an integer var myword = “hello”; //a single word var mylist = [“Retriever”, “Hound”, “Mastiff”, “Beagle”, “Terrier”]; //a list of dog types var draw = function() { //put some code here that will be drawn with every screen refresh }; //in this case we assigned a function to a variable
Loops: We use loops to perform repetitive work. The loop usually continues until a condition is met. Some loops (like the draw() function if defined), will loop endlessly.
This is an example of a “for” loop. The for loop continues “for as long as the condition is true”.
for ( var i = 0; i<10; i++) { println(i); }
Conditionals: Conditionals allow us to make decisions and perform different code based on the outcome. For example:
var x = 10; if(x < 10) { println(“x is less than 10”); } else { println(“x is greater than or equal to 10”); }
Lists: tbd
Functions: tbd |
Activities > Girls Who Code Club >