JavaScript is the programming language of the web.
It can calculate, manipulate and validate data.
console.log("Hello World");
Variables are Containers for Data
In JavaScript, we use the var or let keywords to declare variables.
let x = 5;
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 (x > 0) {
console.log("positive number");
}
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 (let i = 0; i < 3; i++) {
console.log("Hello, world!");
}
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.
funtion greet() {
console.log("Hello World");
}