Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAndrew Alvarez
11,964 PointsArray Object
Challenge Task 2 of 2
Inside the array literal, add three object literals. In other words, the objects array should have three values. Each object should have 2 property/value pairs. Important: The code you write in each task should be added to the code written in the previous task
so am i supposed to add strings?
var objects = [
'objects'
]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
2 Answers
eck
43,038 PointsAn object literal is not a string, but another data type that looks like this: { propertyName: propertyValue }
So if you add three of these objects with two properties then you should be good!
To read about object literals go here.
Unsubscribed User
Courses Plus Student 7,294 PointsHi Andrew, I am adding in one object literal to your array:
var objects = [
{question: "blue + yellow",
answer: "green"
},
add two more object literals here
]
The object literal above has the 2 property/value pairs (question and answer).
Unsubscribed User
Courses Plus Student 7,294 PointsUnsubscribed User
Courses Plus Student 7,294 PointsHi Andrew, Inside the array literal, place 3 object literals. So, going off of what is in your scripts.js:
var objects = [ {question: "red + yellow", answer: "orange" }
]
I added one object literal. This array literal just needs two more. This is my first answer, so I am still figuring out the syntax.