We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Loops

A traditional "for loop" in JavaScript looks like this:

for (let i = 0; i < 5; i++) {
  console.log(i);
}
// 0
// 1
// 2
// 3
// 4

This syntax is common in C-style languages. In English, the code says:

  1. Start with i equals 0. (let i = 0)
  2. Start a loop iteration if i is less than 5. Otherwise, exit the loop.
  3. Log i to the console. (console.log(i))
  4. Add 1 to i. (i++)
  5. Go back to step 2.

Assignment

Complete the bulkSendCost function. It takes as input a number and returns a number.

For example, for four messages:

  • Message 1: 1.0 + 0.00
  • Message 2: 1.0 + 0.01
  • Message 3: 1.0 + 0.02
  • Message 4: 1.0 + 0.03
  • Total: 4.06