skip navigation

Random Numbers

math.floor(math.random()*range)+1

Loops

While: (a condition is true) {run the code block}

Do While: run once before checking the condition and then loop

For: (i=0 (usually); run loop while condition true; i++) {code block}

Arrays

Array.length : number total items in array

Array.length - 1: To get the end of the index

Array.includes ('') : returns boolean of whether the argument is in the array

Arrow Function

Element => element*2;

Expressions

Function expressions don't have to be named and can create anonymous functions. Can run as soon as it is defined, don't need to declare it. They are not hoisted

Function expression

Let varName = function (parameters) { code block Return value};

Arrow expression

let varName = element =>element*2;

Other fun things

Binary tree

Scaling