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.

Creating a number object

Creating a number object

- [Instructor] We will need lots of custom behavior from the number that we will display on the screen. So we will create a JavaScript object to represent it. This way, the functions that we will be creating to manipulate the number, such as transformational operations, color configurations, et cetera, can remain grouped under the object that we will create. This will help with the organization of the program. We will call this new object, guessItem. I'm aware that this is not the greatest name but as they say, there are two hard things in computer science, Cache Invalidation, Naming things and Off-by-1-Errors. Let's create this guessItem object. To be able to do so, I will be creating a constructive function called guessItem, which is going to take three arguments, x position, y position, and the scale value. And it'll say these arguments inside the object by using this keyword, and I will be saving the scale value…

Contents