Javascript

Running the "Hello World" in Javascript.

console.log("Hello World");
Hello World

Math Operations in Javascript

Javascript allows for calculations through code.

var a = 15;
var b = 5;

let sum = a + b;
let total = a * b;
let exponent = a ** b;

console.log(sum) // Should print 20
console.log(total) // Should print 75
console.log(exponent) // Should print 759375
20
75
759375

Using an Array

This is sort of like a list in python. Has multiple indices.

var apps = ["YouTube", "Chrome", "Clash of Clans"];
console.log(apps)
console.log(apps[1])
apps.push("Camera")
console.log(apps[3])
[ 'YouTube', 'Chrome', 'Clash of Clans' ]
Chrome
Camera

The array helps to compile data into a central object. The whole list can be printed by the console, or just a specific index. Additional items can also be appended to the array.

function factorial(x) {
    if (x === 0 || x === 1) {
      return 1;
    } else {
      return x * factorial(x - 1);
    }
  }
console.log(factorial(4))
console.log(factorial(1))
24
1