After configuring exercism command-line client and fetching your first JavaScript exercise (see command-line interface overview) is 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 Installing JavaScript step:
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
To create a module that can be loaded with var Bob = require('./bob.js');, put this code in bob.js:
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.
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.
- Download the Exercism.io Visual Studio Template from GitHub by clicking the Download Zip button on the page.
- Unzip the template into your exercises directory, for example
C:\src\exercises - Install the Exercism CLI
- Open a command prompt to your exercise directory
- Add your API key to exercism
exercism configure --key=YOUR_API_KEY - Configure your source directory in exercism
exercism configure --dir=C:\src\exercises - Fetch your first exercise
exercism fetch javascript - Open the Exercism solution in Visual Studio
- Expand the Exercism.javascript project
- Click on Show All Files in Solution Explorer (See below)
- The exercise you just fetched will appear greyed out. Right click on the folder and Include In Project
- Get coding...
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.
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.
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.

