Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- The for Loop 4:52
- Create a for Loop 1 objective
- Dynamically Display HTML with a Loop 6:52
- Exit a Loop
- Terminate a Loop 1 objective
- The Refactor Challenge 3:00
- The Refactor Challenge – One Solution 3:05
- The Refactor Challenge – Duplicate Code 6:01
- Review for Loops and Exiting Loops 6 questions
- Refactor Code with a Loop 1 objective

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
This video covers one way to prevent duplicating code in your program with a loop and a function.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Tao Zhang
3,546 Points2 Answers
-
Isabelle Johnson
5,547 Points1 Answer
-
Pavlos Valamontes
Front End Web Development Techdegree Graduate 13,983 PointsHere is my solution!
0 Answers
-
Joshua Moten
2,404 Points1 Answer
-
Isabel Mayoral
1,735 Points1 Answer
-
Berian Lowe
22,438 Points1 Answer
-
Jason Swoboda
Full Stack JavaScript Techdegree Student 1,525 Points3 Answers
-
Brian Cumalander
2,725 Points1 Answer
-
Peter Huang
5,427 Points1 Answer
-
suthin
5,997 Points1 Answer
-
PLUS
Stephen Cole
Courses Plus Student 15,810 Points1 Answer
-
Dominick Chism
8,857 Points2 Answers
-
PLUS
Jesse Benedict
Courses Plus Student 4,338 Points1 Answer
-
Jessaly Sinchico
1,485 Points2 Answers
-
Eduardo Vargas
5,871 Points1 Answer
-
bobcat
13,623 PointsWhy use a variable to store the random RGB colours, instead of just returning the result to the function?
Posted by bobcatbobcat
13,623 Points1 Answer
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
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