"JavaScript Loops, Arrays and Objects" was retired on December 18, 2020. You are now viewing the recommended replacement.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Practice Object Basics in JavaScript!
You have completed Practice Object Basics in JavaScript!
Preview
Solution video for first code challenge
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
[MUSIC]
0:00
For your first practice code challenge,
0:09
you were supposed to create an object
literal that had a property called string.
0:11
So follow along to see the solution.
0:15
The value for string was a simple phrase.
0:17
Programming with treehouse is fun.
0:19
This object literal was supposed to be
held in a variable called myString.
0:22
Let's get started.
0:26
First, declare your variable.
0:27
I'll set the variable to
a pair of curly braces.
0:32
These curly braces indicate an object,
and an object's properties and
0:36
methods go inside the curly braces.
0:39
So add some space inside and
then put the property.
0:43
I don't need to put any quotes
around the property key string, but
0:53
I do need quotes around the property
value, because the value is a string.
0:56
The property key and
property value are separated by a colon.
1:01
Now, that's really all there is to it.
1:04
We've created an object literal
with one property, string.
1:06
If we want,
1:11
we can see the value of the myString
variable by logging it to the console.
1:11
So now I'm gonna save the file and
then jump down to the terminal.
1:21
I'll use node, which is a way to
run JavaScript outside the browser,
1:26
to run the file and see the output.
1:29
Cool, as you can see in the output here,
1:35
my string contains an object
with the property string.
1:37
And the value of the property is
Programming with Treehouse is fun!
1:41
Great, let's build on this
in the next code challenge.
1:44
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up