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 trialJames Barrett
13,253 PointsStruggling to understand how the profile.js communicates with router.js
Hello World,
As the question states, I am struggling to understand how the profile.js is communicating with router.js, in particularly:
var studentProfile = new Profile(username);
When we write this line of code, are we basically saying that we are calling the function 'Profile' in 'profile.js' with our username (as a parameter) which we created earlier?
If so, how does the body
variable (which I assume contains all of the JSON returned from https://teamtreehouse.com/ in profile.js) get returned to the studentProfile
?
Perhaps it's my lack of understanding of the .on
method which is throwing me off a little.
Thanks, James.
1 Answer
Jason Morton
8,004 PointsI beleve based on setting the Profile variable in the top of the router document we are communicating that we want to use Profile Method inside the profile.js