Skip to content
Snippets Groups Projects

JavaScript Practice

A collection of small JavaScript exercises for practice when learning the language.

Quick Start

Recursively clone this repository and cd into the root folder:

$ git clone --recursive git@git.unl.edu:csce-310/javascript-practice.git
$ cd javascript-practice

(If you forget --recursive when cloning, you can cd into your clone and run git submodule update --init --recursive instead.)

Install dependencies:

$ npm install

Optionally run the linter and the test suite:

$ npm run lint
$ npm run test

Exercises

In the src folder there are 19 folders lettered a to s, each named for some feature of the JavaScript language and containing an exercise on using that feature. Within each folder are three files:

  • An ordinary *.js file. This file will contain a small piece of starter code and comments with instructions on what code to write where the comment appears. You can edit this file to solve the exercise.

  • A *.key.js file. This file contains a solution to the exercise in case you get stuck.

  • A *.test.js file. This file contains test cases to check your solution. In case the instructions are unclear, you can also read these test cases to better understand what the code under test should do.

Once you have attempted an exercise, you can save your changes to the *.js file and then test your work with a command like

$ npm run test-once:a

where the letter after the colon is the letter of the exercise. These test scripts are also available from the "NPM SCRIPTS" tray in VSCode.

To check your code style, use the command

$ npm run lint

Or run the lint task from the "NPM SCRIPTS" tray in VSCode. Note that the linter may report some style errors for exercises that you have yet to complete.