JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Skip to content
Gallery
duke 3
read me first
review and control structures
if construct
Loop (Unconditional)
Lists
functions
Celebrate
More
Share
Explore
Loop (Unconditional)
repeat a block of code
workshop tickets 1
create multiple copies of a ticket for an event by using a for-loop
workshop tickets 2
create a personalised ticket for each person in a group
workshop tickets 3
calculate total seating for each person in every team using running total
Bus Pass
Debug task: can you find and fix the errors
Track Times
Debug
Repetition
A popular children’s song has repetition
The bell on the bus goes
Ding, ding, ding
Ding, ding, ding
Ding, ding, ding
The bell on the bus goes
Ding, ding, ding,
all day long.
This can be written using a loop (x3)
The bell on the bus goes
Ding, ding, ding
(x3)
The bell on the bus goes
Ding, ding, ding (x1)
all day long.
The words are written
once
alongside the
number of repeats
needed
If you would like to sing along to the song maybe you would like this
video clip
control structure: loop
We already know that iteration means that a loop will make a block of code repeat.
The diagram below introduces the idea that the projects in this section will explore in much more detail
loop 5 times
get a name
display the name
end loop
Repetition
control structure: loop
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
Ctrl
P
) instead.