You can visit us at:
You can print information to the screen and ask the user for information. Programs execute commands in order from top to bottom.
Examples of printing to the screen:
Variables can be used to remember things for later. You can store strings, numbers, and almost anything in a variable. Variables are forgotten when the program finishes running.
Examples of setting variables:
Examples of using variables:
You can compare variables to things, including other variables. When the comparison is true, the code inside the "if" statement is used, otherwise it is not. "else" can be used when the original comparison was not true.
Examples of comparing with "if":
Examples of comparing with "if" and "else":
Examples of comparing with "if", "else", and "else if" with an "and":
Loops run the same code over and over again until a condition is met, like an if statement that runs when true, then starts over and checks again.
Example of while loop:
Example of for loop:
Arrays and simple objects are complex variables that can store multiple pieces of information. An array is a series of related variables, while an object contains key-value pairs of variables.
Examples of an array:
Example of an object:
Example of an array of objects:
Functions create blocks of reusable code that can be altered by parameters and can return information back. They are "called" to run the code, passing in different parameters and receiving values back.
Examples of a simple function:
Example of a function with parameters:
Example of a function with parameters and a return value: