🗂️ Lesson 7: Objects & Arrays
⏱️ Estimated time: 35 minutes | Difficulty: Intermediate
Organizing Data
Arrays and Objects are the primary ways to store collections of data in JavaScript. Arrays are ordered lists, while Objects are collections of key-value pairs.
Creating Functions
function greet() {
console.log("Hello!");
}
greet(); // Call the function
Functions with Parameters
function greet(name) {
console.log("Hello, " + name);
}
greet("Alice");
greet("Bob");
Return Values
function add(a, b) {
return a + b;
}
let result = add(5, 3);
console.log(result); // 8
Arrow Functions
const multiply = (a, b) => a * b;
console.log(multiply(4, 5)); // 20