Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
Let's practice simple JavaScript array skills like creating array literals, accessing, adding and removing array elements, and more.
Related Course
Related Videos
- 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.
Installing Node
[MUSIC]
0:00
Hey everyone,
0:02
Dave here.
0:07
Practice is a good thing.
0:11
It helps make what you’ve
learned last longer.
0:12
It also helps you become a faster and
better developer.
0:14
So let’s practice some basic JavaScript
to make sure your knowledge sticks.
0:17
This practice session covers working
with basic array notation and
0:22
methods in JavaScript.
0:25
It's a great follow-up to the second part
of the JavaScript Loops, Arrays, and
0:27
Objects course.
0:30
If you haven't taken that yet and
find this practice session too difficult,
0:32
then go through that
section of the course.
0:35
I've added a link in the teacher's notes.
0:37
You'll work on three
different small projects.
0:40
I've attached a work space to this video.
0:42
Go ahead and open it up.
0:44
The first project is defined
in the 1_create_array.js file.
0:45
You'll create a basic array,
lock some information about the array
0:51
to the console, use various array methods
to add and remove array elements.
0:55
And use the join method to print
the contents of the array to the console.
1:00
Instructions for this project are in
the file, just open the file up and
1:04
follow the step-by-step instructions.
1:08
You'll use the workspace console and
node to run your code.
1:10
When you're done, your output for
this program should look like this.
1:15
The second project is defined
in the 2_loop.js file.
1:22
It asks you to create a function that
builds an array of ten random numbers.
1:26
You'll call the function then use a for
loop to iterate over the array and
1:32
print out each array item to the console.
1:36
The output of the program should
look something like this.
1:39
The last project is described
in the 3_deck.js file.
1:50
And it's a big challenge.
1:56
You'll create a function that builds
a two-dimensional array, a deck of cards.
1:58
A two dimensional array
is an array of arrays.
2:03
That is, it's an array where each
value inside is another array.
2:06
This file example_2D_array.js
is the array that you'll create.
2:10
Each item in the array is another array
made up of two strings, a rank and a suit.
2:17
For example, ace and spades.
2:26
But instead of writing out a little array
like this, you'll do it programmatically
2:28
by creating a function that creates
this array in just a few lines of code.
2:32
The function will then pass the array to
another function which we've provided
2:37
to shuffle the deck.
2:41
Finally, you'll print each card
in the array to the console.
2:43
The output of the program will
look something like this.
2:46
Now, there's a lot going on
in this final project, so
2:54
if you find that it's a bit too much for
you, that's okay.
2:57
Try your best, then check out
the solution video to see how I did it.
3:00
This is a pretty challenging
set of projects.
3:04
If you want to do some quick study
before tackling this practice session,
3:07
in the teacher's notes, look for
3:10
links to videos that can help
you solve this challenge.
3:11
But if you're ready, go for it.
3:15
Now if you're having trouble, keep at it.
3:17
The more your brain works,
the more you'll learn.
3:19
But if you just can't figure out one or
more of these,
3:21
jump to the solution videos after this
one to see how I programmed my solutions.
3:24
You need to sign up for Treehouse in order to download course files.
Sign up