📦 Lesson 6: JavaScript Functions
⏱️ Estimated time: 30 minutes | Difficulty: Intermediate
Modularity
Functions are the building blocks of JavaScript. They allow you to define a block of code, give it a name, and execute it as many times as you want.
For Loop
for (let i = 0; i < 5; i++) {
console.log("Number:", i);
}
While Loop
let count = 0;
while (count < 3) {
console.log("Count:", count);
count++;
}
For...of Loop (for arrays)
let fruits = ["apple", "banana", "orange"];
for (let fruit of fruits) {
console.log(fruit);
}
Break and Continue
for (let i = 0; i < 10; i++) {
if (i === 5) break; // Stop loop
if (i === 2) continue; // Skip this iteration
console.log(i);
}