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 trialRaeed Sabree
10,664 PointsInside the array literal, add three object literals. In other words, the objects array should have three values. Each
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
var objects = [];
;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Objects</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
Raeed Sabree
10,664 PointsHey they want me array to have 3 values i tried var objects =[milk,eggs,cereal]; but that didnt work
1 Answer
Steven Parker
231,236 PointsYou need 3 object literals. Each of these needs two property/value pairs. Each pair wouldl have a property and a value, separated by a colon (:), and the entire object would be inside braces {}. And remember - 3 of those.
Also, if your values are to be strings, they must be in quotes (" or ').
Raeed Sabree
10,664 Pointscan you show me what it would look like?
Steven Parker
231,236 PointsFor example, ONE object literal might look like this:
{drink: "milk", food: "cookies"}
Your array will contain 3 like this, separated by commas (,), and the whole thing inside the brackets ([]) that you already have.
Raeed Sabree
10,664 Pointsfor some reason its not working for me
Steven Parker
231,236 PointsUpdate the script.js in your question above to show what you are writing as the challenge answer now.
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherRaeed Sabree Hi there! I wish I knew what you had tried already that's failing so that we can better help you to understand whatever it is that's not working. I feel like that it would provide a better learning experience for you than just handing over the solution. Can you give us some indication of what's not clear? Thanks!