Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Introducing the Practice2:49 with Dave McFarland
- The Object Literal
- Accessing Object Properties
for into Loop Through an Object's Properties
- Mixing and Matching Arrays and Objects
Using the practice files
Use the workspace attached to this video to complete the project, or download the project files. If you wish to download the files and work on this project with your own text editor on your program, you'll also need to install Node to test your solution.
Hey everyone, Dave here.
Practice is a good thing.
It helps make what you've learned last longer.
It also helps you become a faster and better developer.
If you haven't taken that yet and find this practice session too difficult,
then go through the course first, I've added a link in the teacher's notes.
You'll work on three different small projects.
I've attached a workspace to this video, go ahead and open it up.
The first project is to find in the 1_object.js file.
You'll use object literal syntax to create a simple object and use a for
in loop to print the properties and values of the object to the console.
Instructions for this project are in the file.
Just open up that file and follow the step-by-step instructions.
You'll use the workspace console to run your code using node.
When you're done, you should see output like this.
The second project is defined in the 2_ product.js file.
It asks you to create a new object named product with three properties for
a single product.
A name, the number of items in the inventory for that product,
and the unit price, which is the cost of a single product.
For example, there might be five chairs in stock each costing $45.
You'll next create a couple of functions.
One to add items to the inventory and another to process a sale.
The steps are described in the file.
The output of the program should look something like this.
The last project is described in the 3_final products.js file and
requires that you create an array of objects.
You'll add two functions, one to return a list of the names of all the products, and
another to calculate the total value of all the products in the array.
When you run the program.
Your output should look like this.
This is a pretty challenging set of projects.
If you wanna do some quick study before tackling this practice session, look in
the teacher's notes for links to videos that can help you solve this challenge.
But if you're ready to go, go for it.
If you're having trouble, keep at it.
The more your brain works, the more you'll learn.
But if you just can't figure out one or more of these,
jump to the next video to show you how I programmed the solution.
You need to sign up for Treehouse in order to download course files.Sign up