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 trialKevin Lozandier
Courses Plus Student 53,747 PointsProfile function inside Profile.js error-prone when used due to declaration of ProfileEmitter without var/let/const
The provided profile.js
file that finally gets explicitly get used in this lesson of the course is prone of throwing an exception—a ReferenceError
because the variable proifleEmitter
inside the Profile
constructor function is attempted to be rebinded w/ this
without being declared properly within the function.
Accordingly that expression on line 14 needs to be changed to the following way inside all the exercise files to avoid this exception from propagating :
var ProfileEmitter = this;
// For the curious, better (iojs/babel-node env, outside the scope of the course): let ProfileEmitter = this;
// For the extra curious, best: const ProfileEmitter = this; or not use a variable for `this` at all or an object literal w/ an init func to avoid a function & new at all. Also outside the scope of the class.
Used the latest version of Node.js & iojs (1.8.1
) available via source or nvm
on the latest version of Mac OS X Yosemite.
Andrew Chalkley perhaps may have experienced something differently running the script?
Allison Walker
17,137 PointsAlso your code has typos.
Allison Walker
17,137 PointsAllison Walker
17,137 PointsThanks for this, but this isn't fixing my error.