Giter VIP home page Giter VIP logo

cc-fs-3-02-17-pr-mocha-factorial-feature's Introduction

CodeCademy Project

Full-Stack Engineer Path > Front-End Development > JavaScript Syntax, Part III

Project (3-17) Factorial Feature - The goal of this short project is TDD of JavaScript code using Mocha. In order to test the index.js file, we need to use Node.JS and install Mocha:

npm init

Then

npm install mocha -D

Factorial Feature

In this project, you will use test-driven development to build a factorial method. You will use the assert module and mocha testing library to drive your development using tests that follow the phases: setup, exercise, and verification. How To Calculate Factorial

You take an integer and you multiply that by all the integers that are less than it.

The factorial of an integer n is denoted by an exclamation mark n!, so 5! is equal to:

5 × 4 × 3 × 2 × 1 = 120

Edge Case

An edge case is a problem or situation that occurs only at an extreme (maximum or minimum) operating parameter — you can think of these as special cases that you need to account for. Based on the logic of factorials, you would expect that calculating 0! would look like this:

0 × 0 = 0

But mathematically this is not true. In this instance of a factorial method, there is an edge-case which is that 0 factorial (or 0!) is 1.

The steps below follow the red-green-refactor cycle and will guide you through the process of using test-driven development to create a factorial method. The factorial method will be inside an object named Calculate. You will be implementing your test code in the file index_test.js, and your implementation code in index.js.

After you complete each step, run the test suite in the terminal to test the results.

If you get stuck during this project, check out the project walkthrough video which can be found at the bottom of the page after the final step of the project.

cc-fs-3-02-17-pr-mocha-factorial-feature's People

Contributors

chrisbourgeonnier avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.