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 Uses for Closures

Sean Flanagan
Sean Flanagan
33,235 Points

Wrong workspace

Hi. I noticed that the workspace in the video is completely different to the workspace that opens when I click the Launch Workspace button. Why is this? Has there been a mistake or something?

5 Answers

Autumn Wind
PLUS
Autumn Wind
Courses Plus Student 6,282 Points

I had the same problem. It seems there is a bug, but you can get around it by the following steps:

  1. Click "Launch Workspace"
  2. When the modal window pops up: Click "Launch Different Workspace"
  3. Fill out the form: Enter a title (e.g. "My Uses for Closures"), select "Any Environment," and finally, select the workspace template that matches the name of this video ("Uses for Closures").

Submit the form, and that should get you the right workspace.

I'll pile on: The wrong workspace is also launching for me, it matches the one Sean Flanagan has posted below.

The wokspace that's being launched instead: Node.js Basics - Handling Parsing Errors with try and catch

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! When I click the launch workspace button, it launches a workspace that matches the video. That being said, the workspace that you'll be using isn't shown until around 2 minutes into the video. The first part of the code that is shown is the "morgan" middleware code.

If the workspace you're finding doesn't match the video at 2:14, I would highly suggest you report this to Support at help@teamtreehouse.com.

Hope this helps! :sparkles:

Sean Flanagan
Sean Flanagan
33,235 Points

Hi Jennifer. Thanks for your reply. I clicked on 2 minutes 14 seconds on the video. Then I clicked Launch Workspace. The workspace I have doesn't match. It has an app.js file. Here's its code:

// 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

// Require https module
const https = require('https');

// Print error messages
function printError(error) {
  console.error(error.message);
}

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

function getProfile(username) {
  try {
    // Connect to the API URL (https://teamtreehouse.com/username.json)
    const request = https.get(`https://teamtreehouse.com/${username}.json`, response => {
                            if (response.statusCode === 200) {
                              let body = "";
                              // Read the data
                              response.on('data', data => {
                                body += data.toString();
                              });

                              response.on('end', () => {
                                try {
                                  // Parse the data
                                  const profile = JSON.parse(body);                            
                                  // Print the data
                                  printMessage(username, profile.badges.length, profile.points.JavaScript);
                                } catch (error) {
                                  printError(error);
                                }
                              });
                            }
                          });
    request.on('error', printError);
  } catch (error) {
    printError(error);
  }
}

const users = process.argv.slice(2);
users.forEach(getProfile);

I've told Support about this.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Sean Flanagan my best suggestion to you right now is to delete that workspace. Click on the workspace link at the top here and find it and delete it. The next time you click "Launch Workspace" it should create a new workspace with the files for that video. If this still doesn't work, you should definitely contact support.