Introduction
Welcome to the world of functions in JavaScript!
Functions are reusable blocks of code that perform specific tasks. They help make your code cleaner and more organized.
Variables
Variables are named storage locations that hold data. You assign values to variables using the assignment operator (=).
Example: `let myName = "John";`
Data Types
Different data types represent different kinds of information. Examples include: Number, String, Boolean, Array, Object.
Number: Can be integers or decimals.
String: Text (enclosed in single or double quotes).
Boolean: True or False.
Array: An ordered collection of items.
Object: A collection of key-value pairs.
Operators
Operators are symbols that perform operations on values. Examples include: Addition, Subtraction, Multiplication, Division, Comparison (equals, greater than, less than).
Addition: Adding two numbers together.
Subtraction: Subtracting one number from another.
Multiplication: Multiplying two numbers together.
Division: Dividing one number by another.
Control Flow
Control flow determines the order in which your code is executed.
If: Executes a block of code only if a condition is true.
Else: Executes a block of code if the condition is false.
While: Executes a block of code as long as a condition is true.
For: Executes a block of code a specific number of times.
Functions
Functions are reusable blocks of code that perform specific tasks. They can help you organize your code and make it more readable.
Example: `function greet(name) { return 'Hello, ' + name + '!'; }`