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 trialshirshah sahel
10,035 PointsStuck here, when I type Node app.js it would'nt show me the total number of badges and points in javascript .
https://w.trhou.se/6dun89f45p attach is the link to my workspace . I am wondering why it is not showing the total of badges and points in javascript for co workers. Thanks,
//Require https module
const https= require('https');
//Function to print message to console
function printMessage(username, badgeCount, points){
const message=`${username} has ${badgeCount} badges and ${points} points in javascript`;
console.log(message);
}
function getProfile(username){
// Connect to the API URL (https://teamtreehouse.com/username.json)
const request= https.get(`https://teamtreehouse.com/${username}.json`, response =>{
let body="";
// Read the data
response.on('data',data=>{
body += data.toString();
});
response.on('end', ()=>{
// Parse the data
const profile= JSON.parse(body);
printMessage(username, profile.badges.lenght, profile.points.javascript);
// Print the data
});
});
}
getProfile("chalkers");
getProfile("alenahollingan");
3 Answers
Steven Parker
231,269 PointsOn this line:
printMessage(username, profile.badges.lenght, profile.points.javascript);
You have "lenght" instead of "length" and "javascript" instead of "JavaScript" (identifiers are case-sensitive).
And on this line:
getProfile("alenahollingan");
That should be "alenaholligan" (just two "n"s).
Also, depending on what version of Node.js you're using, you might not be able to use "let" unless you're also using "strict" mode.
shirshah sahel
10,035 PointsAwesome Steven, it totally worked . I need to practice how to type length.
Amanda Sharp
15,223 PointsAnd to add on Steven's point
'javascript' should have capital letters like so:
printMessage(username, profile.badges.lenght, profile.points.JavaScript);