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 look at a way to make our branching logic more readable.
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
There's a complex if else statement
inside it that is a little hard to read.
0:00
Each if statement examines the text
content of a button that was clicked
0:02
to determine which block runs.
0:07
Now you might know this
is called branching,
0:09
because this is like a fork in
the road in the flow of our program.
0:11
The program will take only
one of these three branches,
0:15
after it looks at the button name.
0:19
So all the branches are fused
together into a single block of code.
0:22
So what if we put each branch
into its own function?
0:27
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