Honk your horn with a button on Code Car, but this time using a variable.
How many can you complete? Change the code according to the challenges below. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!
New Concept: Variables Replace Fixed Numbers
Variables are something that you interact with all the time and they're a very important concept in coding. In this lesson, you're simply replacing a fixed number with a variable. But imagine if you had written 1000 lines of code that all relied on pressing button 8, then button 8 broke! It would be so much easier to have a variable 'button' standing in for button 8 that you could change in one location and affect the rest of your code.
There are a number of different ways to use variables in coding (you'll see more ways in future lessons), but their purpose is always to make code easier to understand, simpler to change, and less repetitive.