Loops - Activity

Loops

Make sure you attempt the activity on your own before checking out the solution.

Instructions

  1. Use a loop to render the numbers 5 through 9.
  2. Use a separate loop to render the word piggywooo five times.

Challenge:

Google the JavaScript decrement operator.

  1. Using the decrement operator, render the numbers 10 through 0.
Solution
for (let i = 5; i < 10; i++){
  console.log(i);
}

for (let i = 0; i < 5; i++){
  console.log('piggywooo');
}

// Challenge

for (let i = 10; i >= 0; i--) {
  console.log(i);
}