Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Node.js Basics 2017 Building a Command Line Application Capturing Command Line Arguments

Why not working? My code is perfect. https://teamtreehouse.com/workspaces/33084322#

Why isn’t this working? It should be perfect.

ERROR MESSAGE: “SyntaxError: Unexpected token” https://teamtreehouse.com/workspaces/changelog

MY CODE BELOW:

const https = require('https');

function printMessage(username, badgeCount, points) { const message = ${username} has ${badgeCount} total badge(s) and ${points} in JavaScript ; console.log(message); }

function getProfile(username){

const request = https.get(https://teamtreehouse.com/${username}.json, response => { let body = ""; response.on('data', data => { body += data.toString(); });

response.on('end', () => { const profile = JSON.parse(body); printMessage(username, profile.badges.length, profile.points.JavaScript); });

      });

    }

getProfile("chalkers"); getProfile("alenaholligan");

2 Answers

Dave StSomeWhere
Dave StSomeWhere
19,822 Points

I'm pretty sure that there is no such thing as perfect code. hehe

Don't you at least need tics for your template code?

Steven Parker
Steven Parker
217,443 Points

If there was "perfect" code, you'd never have to ask why it wasn't working. :smirk:

Pepe Toño
Pepe Toño
13,814 Points

You are missing inverted ticks on the first argument of the https.get() method. Write it like this https://teamtreehouse.com/${username}.json