After configuring exercism command-line client you can fetch the very next exercise

1
exercism fetch javascript

or you can fetch a specific exercise, passing the exercise name after the language. For example, to fetch the bob exercise:

1
exercism fetch javascript bob

Now, it's time to run some tests. Move to the folder where that exercise's files are located (a path similar to <EXERCISM_HOME_DIR>/<TRACK_ID>/<EXERCISE>) and run the tests with the jasmine-node command you should have installed on the Installing JavaScript step:

1
2
cd ~/exercism/javascript/bob
jasmine-node bob_test.spec.js

Note that ~/exercism is the default folder for EXERCISM_HOME_DIR. Be sure you use your configured folder for it

Making Your First Node Module

To create a module that can be loaded with var Bob = require('./bob.js');, put this code in bob.js:

1
2
3
4
5
6
7
8
9
var Bob = function() {};

Bob.prototype.hey = function(what) {
  //
  // Your solution to the exercise goes here
  //
};

module.exports = Bob;

You can find more information about modules in the node documentation. To make it easier to get started, there's a "skeleton" bob.js file in the directory for the first exercise.

Visual Studio on Windows

Install Visual Studio Express 2013 for web. This will include the IDE and web development tools.

To get started, you can download a Visual Studio solution that is already set up to work with JavaScript and the other languages that Visual Studio supports.

Solution Explorer

  1. Download the Exercism.io Visual Studio Template from GitHub by clicking the Download Zip button on the page.
  2. Unzip the template into your exercises directory, for example C:\src\exercises
  3. Install the Exercism CLI
  4. Open a command prompt to your exercise directory
  5. Add your API key to exercism exercism configure --key=YOUR_API_KEY
  6. Configure your source directory in exercism exercism configure --dir=C:\src\exercises
  7. Fetch your first exercise exercism fetch javascript
  8. Open the Exercism solution in Visual Studio
  9. Expand the Exercism.javascript project
  10. Click on Show All Files in Solution Explorer (See below)
  11. The exercise you just fetched will appear greyed out. Right click on the folder and Include In Project
  12. Get coding...

Add files

If you have a paid version of Visual Studio, you should install the Web Essentials extension. It will make working with Javascript much easier.

You can run the unit tests from a node.js command line using the batch file in the project.

1
2
3
4
5
C:\Src\exercises\javascript>test example\bob_test.spec.js
.................

Finished in 0.02 seconds
17 tests, 17 assertions, 0 failures, 0 skipped

If you do not see any output from running the tests, you are likely not in a Node.js command prompt.

Setting Up a Linter

A linter is like a tester for your code's style and formatting. In some languages there are many acceptable styles, and using a linter allows you to be internally consistent (e.g. Ruby), or adhere to one of many common styles. In other languages there are fewer choices, and a linter allows programmers to look at code from a great variety of sources and still feel at home (e.g. Go). You can read more here.

The old standard linter for JavaScript is JSLint. However, it is controversially picky. JSHint is another popular linter. We suggest using ESLint, which is more customizable than either JSLint or JSHint, and is well-run.

To get started using ESLint, follow the instructions here. Once you have ESLint installed, you'll be able to lint your code with a simple eslint [options] [file|dir]* command. Eg, if you're in the hello-world directory, eslint . would lint all files in that directory.