Rated A+
For Loop ✔✔for(var i = 0; i < COUNT; i++){
}
While Loop ✔✔while(boolean expression){
/* Repeat code betweeen brackets while
* 'boolean expression' is true */
}
If Statement ✔✔if(BOOLEAN_EXPRESSION){
// code to execute if true
}
If/Else ✔✔if(BOOLEAN_EXPRESSION){
// code if true
} else {
// code if false
, }
Functions ✔✔/ Functions can take in values, called parameters.
// The function below takes in a parameter called
// 'input' and prints it.
function printText(input) {
println(input);
}
Functions using return ✔✔function addTwo(number) {
return number + 2;
}
Returns the width of the canvas ✔✔getWidth();
Returns the height of the canvas ✔✔getHeight();
Returns the x coordinate of the center of the canvas ✔✔getWidth() / 2;