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 trial

JavaScript

node.js

//Problem: We need a simple way to look at a user's badge count and javascript points.
//Solution: Use Node.js to connect to treehouse's API to get profile information to print out.


function printMessage(username, badgeCount, points){
  var message = username + ' has ' + badgeCount + ' total badges and ' + points + ' points in JavaScript.';
  console.log(message);
}

//Connect to the API URL (https://teamtreehouse.com/username.json
 //Read the data
 //Parse the data
 //Print the data
});
printMessage("Chalkers", 1000, 2000000);

After entering in the console node app.js the following syntax error appears:

SyntaxError: Unexpected token }
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3

1 Answer

You have one opening curly brace but two closing braces and an additional closing bracket. My comments are in caps to distinguish them from yours.

//Problem: We need a simple way to look at a user's badge count and javascript points.
//Solution: Use Node.js to connect to treehouse's API to get profile information to print out.


function printMessage(username, badgeCount, points){
  var message = username + ' has ' + badgeCount + ' total badges and ' + points + ' points in JavaScript.';
  console.log(message);
} \\HERE YOU HAVE FINISHED THE FUNCTION

//Connect to the API URL (https://teamtreehouse.com/username.json
 //Read the data
 //Parse the data
 //Print the data
}); \\HERE YOU ARE TRYING TO FINISH SOMETHING A SECOND TIME.
printMessage("Chalkers", 1000, 2000000);

If you get stuck like this again, a great resource on the web is at http://jshint.com/. In this instance the website gets cranky, but your clue is in the error. Syntax errors such as the one you got tend to happen because you haven't opened or closed something correctly (e.g. string, array, function).