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 trialcyber voyager
8,859 PointsI don't understand why we exported only the get function
Hello, as I was watching this video the teacher made a module with most of the code inside it. I don't understand why we exported only on part of the module. Why? the code needs the whole module to work.. Somewhere I am confused. It would be great if someone could explain it to me.
Thanks, Stavros
1 Answer
Evan Demaris
64,262 PointsHi Stavros,
get
is the only function exported because it's the only function you'd actually call in the main app. Meaning, all other functions in profile.js are used by the get
function so they aren't called by the main app directly. When get
is called, it has access to the other functions in profile.js so it works correctly.
Hope that helps!
cyber voyager
8,859 Pointscyber voyager
8,859 PointsGreat answer you made me understand it, I thought that something like that was happening under the hood but I wanted to somewhat sure. Anyways great answer thank you very much!