Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Introducing the Practice3:28 with Dave McFarland
- Create an Array
- Accessing Items in an Array
- Adding Data to Arrays
- Removing Items from Arrays
- Using for Loops With Arrays
- Useful Array Methods
- Two-dimensional arrays
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 computer, you'll also need to install Node to test your solution.
Practice is a good thing.
It helps make what you’ve learned last longer.
It also helps you become a faster and better developer.
This practice session covers working with basic array notation and
If you haven't taken that yet and find this practice session too difficult,
then go through that section of the course.
I've added a link in the teacher's notes.
You'll work on three different small projects.
I've attached a work space to this video.
Go ahead and open it up.
The first project is defined in the 1_create_array.js file.
You'll create a basic array, lock some information about the array
to the console, use various array methods to add and remove array elements.
And use the join method to print the contents of the array to the console.
Instructions for this project are in the file, just open the file up and
follow the step-by-step instructions.
You'll use the workspace console and node to run your code.
When you're done, your output for this program should look like this.
The second project is defined in the 2_loop.js file.
It asks you to create a function that builds an array of ten random numbers.
You'll call the function then use a for loop to iterate over the array and
print out each array item to the console.
The output of the program should look something like this.
The last project is described in the 3_deck.js file.
And it's a big challenge.
You'll create a function that builds a two-dimensional array, a deck of cards.
A two dimensional array is an array of arrays.
That is, it's an array where each value inside is another array.
This file example_2D_array.js is the array that you'll create.
Each item in the array is another array made up of two strings, a rank and a suit.
For example, ace and spades.
But instead of writing out a little array like this, you'll do it programmatically
by creating a function that creates this array in just a few lines of code.
The function will then pass the array to another function which we've provided
to shuffle the deck.
Finally, you'll print each card in the array to the console.
The output of the program will look something like this.
Now, there's a lot going on in this final project, so
if you find that it's a bit too much for you, that's okay.
Try your best, then check out the solution video to see how I did it.
This is a pretty challenging set of projects.
If you want to do some quick study before tackling this practice session,
in the teacher's notes, look for
links to videos that can help you solve this challenge.
But if you're ready, go for it.
Now 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 solution videos after this one to see how I programmed my solutions.
You need to sign up for Treehouse in order to download course files.Sign up