/js-training-tdd

Get good at JavaScript

Primary LanguageJavaScriptMIT LicenseMIT

JS Training with TDD

Credits: Clément Denis for the original repo.

Setup

1. Get this repo

First, fork this repository: you'll then have a copy of this repo under your GitHub account.

Then go to wherever you store your development work, and run these commands to clone the forked repo (replace GITHUB_LOGIN with your login):

# download your code locally
git clone https://github.com/GITHUB_LOGIN/js-training-tdd.git

# change working directory to the newly cloned repository
cd js-training-tdd

Prerequisites: you must have installed Git!

Node.js is a platform which makes it possible to run JavaScript code outside the web browser.

You have to install Node.js, preferably not with the packages on Node's download page.

2. Install Node.js

On Linux/MacOS

Note for Linux users: before going further, run which curl in the terminal. If it shows something (e.g. /usr/bin/curl), you're good! Otherwise, run sudo apt install -y curl (Ubuntu/Debian) to install cURL.

You are going to use NVM (Node Version Manager). Here's a summary of what you have to do (see installation instructions on the NVM repo for more details). Run these commands in your terminal:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
source ~/.bashrc
nvm install v10.16.3
nvm use v10.16.3

You can verify that it worked by running node -v, which should display:

v10.16.3

On Windows

The original NVM doesn't support Windows. You're going to use NVM for Windows. Get to the releases page. Under the latest version (1.1.7 as of September 2019), download the nvm-setup.zip file (or use this direct link).

Extract the archive, and run nvm-setup.exe. Complete the setup wizard. Then, quit Git Bash if it is running, re-launch it, and type:

nvm install v10.16.3
nvm use v10.16.3

Running node -v should display: v10.16.3.

Testing

Once you have coded your masterpiece, you can start testing your solutions.

You can run tests for a single section:

# run the test runner with args ( basics, advanced, math, get)
./tester basics

output-tester-basics

Later on, you may use tester with no argument, to check exercises from all sections (in this example, basics, math and part of str have been solved):

# run the test runner
./tester

output-tester

Solving

You can start editing the JavaScript files with your favorite text editor i.e. VSCode, Atom, Sublime Text, etc.

where-to-code

Get Help!

We maintain an example-based code documentation

All you need to know to solve those exercises is described in them.

And we also made you a curated list of all the most useful methods:

(*) methods in italics are NOT pure (using them with the same arguments won't return the same result). They must be used with caution as it is harder to predict their results