Write a for loop that logs the numbers from 10 down to 1.
Loops let you run the same block of code multiple times without repeating yourself.
Runs a block of code a specific number of times.
Example:
for (let i = 0; i < 5; i++) {
console.log("Count: " + i);
}
Runs a block of code while a condition is true
.
Example:
let count = 0;
while (count < 3) {
console.log("While loop count: " + count);
count++;
}
Runs the block at least once, then repeats while the condition is true
.
Example:
let num = 0;
do {
console.log("Do-while number: " + num);
num++;
} while (num < 2);