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 Defining Variables with let and const!
You have completed Defining Variables with let and const!
Preview
Using the var keyword in for loops can cause unexpected behavior. In this video we'll see how let solves those issues.
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
loop can lead to some really confusing and
unexpected outcomes.
0:00
Let me show you one common example.
0:03
Open buttons.html and
look at this example.
0:06
The program is designed to
select all buttons on the page,
0:11
then the program adds the behavior for
when someone clicks on the button,
0:15
it produces an alert that says button
then the button number pressed.
0:22
The first button should
say button zero pressed.
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