Skip to content

Latest commit

 

History

History
76 lines (47 loc) · 2.79 KB

README.md

File metadata and controls

76 lines (47 loc) · 2.79 KB

JS Training: The Quiz Project

What is it ?

The quiz is a simple quiz built on client from a json file.

The quiz has a simple schema:

Property Definition
title:String Title of the quiz
questions:Array<Object> Config of questions
questions[]:Object
questions[].problem:String Question's title
questions[].input:Object Field to display
questions[].input.type:String 'radio', 'checkbox', 'inputs' or 'input' (default)
questions[].input.options:Array labels of the options (only for 'radio', 'checkbox' or 'inputs')

Why?

It's a project to practice acquired knowledge in JS Training Course refactoring this code.

This code is not meant to be well done, but meant to be refactored. This way, you can refactor progressively fixing the main mistakes of the code.

How?

Please read the contributing guidelines

Commands

npm run dev

Runs the project on watch mode.

npm run test

Executes end-to-end tests on the app to check your change haven't broken anything.

npm run test:dev

Executes "npm run dev" with tests so you can reload them when needed.

npm reset

Safely reinstalls the project.

Refactor phases

1. Operators And Closures

branch-icon refactor/operators-closures

  • Change scopes of variables from global scope to local scope.
  • Declare variables with let, const or var.
  • Use destructuring when possible.
  • Use operator expressions for conditionals and value assignment.

2. Strings

branch-icon refactor/strings

  • Convert strings to template strings.

3. Functions

branch-icon refactor/functions

  • Split all logic in functions as pure as possible.
  • Use new arrow functions syntax when possible.
  • Respect functional principles:
    • Immutability
    • Absence of side effects
    • Function don't depend on state
    • Functions with 1 input/ 1 output.