Section 1 - Instruction

You've learned the differences between for and while loops. Now let's practice recognizing which scenarios call for each type of loop.

Engagement Message

Ready to become a loop selection expert?

Section 2 - Practice

Type

Multiple Choice

Practice Question

Which loop would be best for this scenario: "Print all items in a shopping cart"?

A. for...of loop (for each item in the cart) B. Traditional for loop (counting from 0 to cart length) C. while loop (until condition changes) D. Both A and B would work well

Suggested Answers

  • A
  • B
  • C
  • D - Correct
Section 3 - Practice

Type

Fill in The Blanks

Markdown With Blanks

Fill in the blanks to choose the right loop keywords:

Suggested Answers

  • for
  • while
  • for...of
  • do...while
Section 4 - Practice

Type

Sort Into Boxes

Practice Question

Sort these programming tasks into the correct loop type categories:

Labels

  • First Box Label: Definite (for loop)
  • Second Box Label: Indefinite (while loop)

First Box Items

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal