JavaScript Node.js Basics Handling Errors in Node Organizing Your Code with require

shirshah sahel
shirshah sahel
10,034 Points

I'm having a little trouble with organizing my code with require.

After adding profile.js something is not working properly. I am going to attach my workspace. Thanks for consideration.

https://w.trhou.se/h33cxlhl1t

4 Answers

Neil McPartlin
Neil McPartlin
14,629 Points

You were very close. The clue is in the console error message...

treehouse:~/workspace$ node app.js                                                                                                              
/home/treehouse/workspace/app.js:6                                                                                                              
users.forEach(Profile.get);                                                                                                                     
              ^                                                                                                                                 

ReferenceError: Profile is not defined

'Profile' is not recognised but the word 'profile' is expected. The little ' ^ ' is pointing out the problem. Just replace 'P' with 'p'.

shirshah sahel
shirshah sahel
10,034 Points

https://w.trhou.se/6dun89f45p Thanks for that recommendation Neil. However I still have the issue , I have changed the upper P to lower but still didn't work.

users.forEach(profile.get);

Neil McPartlin
Neil McPartlin
14,629 Points

Hi Shirshah. This new Saturday 'snapshot' is not the one you posted on Thursday. It's from a workspace you were working on a few lessons earlier. To get this snapshot working, you just need to fix a few typos in app.js

Line 25:

//Replace
printMessage(username, profile.badges.lenght, profile.points.javascript);
//With
printMessage(username, profile.badges.length, profile.points.JavaScript);

Line 33:

//Comment out this person as their profile cannot be found.
//Replace
getProfile("alenahollingan");
//With
//getProfile("alenahollingan");
shirshah sahel
shirshah sahel
10,034 Points

Thank you Neil for your time, Got it now.