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 DOM Scripting By Example!
You have completed DOM Scripting By Example!
Preview
Let's take a look at our click handler. There's a repeating pattern that we can write a function to perform, and reduce repetition in our code.
This video doesn't have any notes.
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
The programmer's slogan,
don't repeat yourself,
0:00
is the foundation of dry programming.
0:00
Duplication, not only makes
your programs longer, but
0:02
also makes them more difficult to update.
0:05
Since a change you make in
one part of the program,
0:07
will probably need to be made
wherever the same code appears.
0:09
So let's see if we can simplify
our program by identifying and
0:12
removing duplicate code, for example,
0:16
take a look at the createLI function,
can you spot repeated code here?
0:19
Notice how after the first list
item is created in the first line,
0:25
createElement is called five times.
0:29
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