Change the wording, keep your experiment. Saved in this browser when storage is available.
The question to explore
Make a short playlist
How does a program repeat an action and stop?
About 7 minutes / Suggested pace / No account needed
Try the experimentWhat this activity helps you do
Choose the playlist length and count the additions. A loop repeats a step until it reaches a limit. AI helpers that repeat searches or edits need a stopping rule too.Repeating an instruction saves you from doing the same work by hand. Change the playlist length and count the additions. When an AI helper repeats searches or edits, give that work a stopping condition too.
Local teaching illustration / No AI model call
- Choose 5 in How many songs? Predict how many additions you will see.
- Read the repeated instruction for each song. Notice that the last one adds song 5.
- Change the count to 1, then 8. The same rule builds a different length of playlist.
Predict first: Where will the loop stop if you choose 5 songs?
Add song 1 to the playlist Add song 2 to the playlist Add song 3 to the playlist
Change a control to explore the example when JavaScript is enabled.
The idea
To make five playlist entries, repeat “add the next song” five times. Each repeat is an iteration. Your chosen count tells the loop when to stop.You want five songs in a playlist. The repeated step is simple: add the next song. A loop tells a program to keep doing that step until the playlist reaches the count you chose.
Try one, five and eight entries. The instruction stays the same; the number of repeats changes. This is a local illustration. It does not play music or contact a music service.Each repeat is called an iteration. Try one song, then five, then eight. The numbered list shows every addition and where the loop stops. This is a local playlist illustration; it does not play music or connect to a music service.
Take this with you
What changed?
A loop repeats a step until its stopping condition is met.
Try explaining it.
What if the program keeps adding songs without checking your chosen count?
Open a possible explanation
It would not know when to stop. A count or another clear limit keeps repeated work under control. AI tool loops need limits too.
Choose what to try next
Keep exploring, or stay here and try another variation.