From the course: Coding for Visual Learners: Learning JavaScript from Scratch
Unlock this course with a free trial
Join today to access over 24,400 courses taught by industry experts.
Variables continued - JavaScript Tutorial
From the course: Coding for Visual Learners: Learning JavaScript from Scratch
Variables continued
- [Instructor] To go back to our example, to be able to evaluate expressions like this will help us. But I think the real problem here is that we need to type the same number over and over again in these three function calls. This is repetitive and laborers. This is an instance where usage of variable would be useful. Remember when we needs value, and we need to use that value in multiple places, we would want to store that value in a variable. The advantage of using a variable is that, if you ever needed to update the value of the variable, you would only need to do it in a single place. Let's update this example to use a variable. Remember how to create variables. You will start off by using the Y keywords and then we will choose a name for our variable. It's important to choose a name that makes sense. Calling this variable offsets or X would make sense because we will be using it to offset shapes in the X axis. Using…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.