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

why it called profileJSON? I can't find the a json title is this a rule when parsing data from a JSON response?

It's a curiosity question this

If i go to https://teamtreehouse.com/mattroberts2.json and view the JSON i don't see a profile or profileJSON text anywhere, so how would i know that the values from the JSON can be parsed using

var values = {
        avatarUrl: profileJSON.gravatar_url, 
        username: profileJSON.profile_name,
        badges: profileJSON.badges.length,
        javascriptPoints: profileJSON.points.JavaScript
      }

1 Answer

Steven Parker
Steven Parker
231,153 Points

The "profileJSON" variable was created earlier in code not shown here, and it holds a plain JavaScript object created by converting the file contents (from JSON format).

All this code does is create a new object using selected attributes from the existing one.

For future questions show the whole code and/or provide a link to the course page.