Introduction

JavaScript is the programming language of the web.

It can calculate, manipulate and validate data.

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

    Variables are Containers for Data

    In JavaScript, we use the var or let keywords to declare variables.

  • let
  • let x = 5;
    If...else statement

    Conditional statements are used to perform different actions based on different conditions.

    The JavaScript if...else statement is used to execute/skip a block of code based on a condition.

  • if
  • if (x > 0) { console.log("positive number"); }
    for statement

    Loops can execute a block of code a number of times.

    In JavaScript, the for loop is used for iterating over a block of code a certain number of times, or to iterate over the elements of an array.

  • for
  • for (let i = 0; i < 3; i++) { console.log("Hello, world!"); }
    Function declarations

    A function is an independent block of code that performs a specific task, while a function expression is a way to store functions in variables.

    JavaScript functions are defined with the function keyword.

  • function
  • funtion greet() { console.log("Hello World"); }