Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed JavaScript Loops!
You have completed JavaScript Loops!
Preview
Use `do...while` to create a loop that executes code until the test condition evaluates to false.
Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Now open the file do-while.js and
copy the getRandomNumber
0:00
function from while.js and
paste it inside this file.
0:03
In index.html,
update the script tag source attribute
0:08
to js/do-while.js. The structure of
a do-while loop looks like this.
0:13
The do statement comes first and
is followed by a while condition.
0:20
Do-while repeats an action over and
over again, while a condition is true.
0:26
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up