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 trial

JavaScript AJAX Basics (retiring) Programming AJAX Finish the JSON File

Raeed Sabree
Raeed Sabree
10,664 Points

Add 3 more song objects to this JSON file, each with "title" and "artist" attributes.

what did i do wrong?

songs.json
[ 
  {
    "title" : "My Way",
    "artist" : "Frank Sinatra",

       "title" : "My lay",
    "artist" : "Frank Sinatra",

       "title" : "My pay",
    "artist" : "Frank Sinatra",

       "title" : "My say",
    "artist" : "Frank Sinatra",

           "title" : "My tray",
    "artist" : "Frank Sinatra"



  }
]
Simon Coates
Simon Coates
28,694 Points

Because object data is stored on a particular key, the effect of the above is that title and artist is set 5 times on a single object. The resulting object from your code is [{"title":"My tray","artist":"Frank Sinatra"}]. If each song is an individual object, then title and artist can be properties on each individual song.

2 Answers

Simon Coates
Simon Coates
28,694 Points

this would be one more

[ 
  {
    "title" : "My Way",
    "artist" : "Frank Sinatra"
  },
    {
    "title" : "My Way",
    "artist" : "Frank Sinatra"
  }
]

you get the idea

Here's a concrete example of the syntax you need to have:

[ 
  {
    "title" : "My Way",
    "artist" : "Frank Sinatra"
  },
  {
    "title" : "Walk This Way",
    "artist" : "Aerosmith"
  },
  {
    "title" : "Ace of Spades",
    "artist" : "Motorhead"
  },
  {
    "title" : "Glass Shatters",
    "artist" : "Disturbed"
  }
]