Tutorial on JavaScript

Topics


For Loops

The For Loop will repeat until a specified condition is false. What happens when a for statement is running?

Example of For Loop and how to read one
for (var i = 0; i <= 50; i += 5){
            console.log(i);
This is read as, "Variable i starts at 0, we are counting up to 50, and we are counting to 50 by 5's."

Arrays

An array is a numerically indexed map of values. Starts at 0. Here are some key points:

Here is an Example
let colors =["Red", "Green", "Blue", "Purple", "Orange"];
          console.log(colors[3]); 
In this console.log, we are calling out index value 3, which would give us a result of Purple.

Functions

A function allows us to execute some action or actions. A few key parts to functions:

A small example, written two ways
function hi() {
            console.log('hello!');
        }

        
        hi();
Here we have named the function "hi", and want to give it the result "hello!" when we call it.