From f61fc079aeadde1628c77b695c21d006d4331717 Mon Sep 17 00:00:00 2001 From: Kamila Lambert Date: Mon, 8 May 2017 14:56:35 -0700 Subject: [PATCH] all factorial tests passing --- src/factorial.js | 9 +++++++++ test/factorial_test.js | 13 +++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/factorial.js create mode 100644 test/factorial_test.js diff --git a/src/factorial.js b/src/factorial.js new file mode 100644 index 0000000..8376a1e --- /dev/null +++ b/src/factorial.js @@ -0,0 +1,9 @@ +export default function factorial(input) { + + let multiplyNumbers = [] + + for (let i = input; i > 1; i--) { + multiplyNumbers.push(i) + } + return multiplyNumbers.reduce(function(a, b) {return a * b}) +} diff --git a/test/factorial_test.js b/test/factorial_test.js new file mode 100644 index 0000000..bd3f790 --- /dev/null +++ b/test/factorial_test.js @@ -0,0 +1,13 @@ +import { expect } from 'chai' +import factorial from '../src/factorial' + +describe.only('factorial()', function(){ + + it('should be a function', function(){ + expect(factorial).to.be.a('function') + }) + + it('returns an array of numbers 1-100, fizz for multiples of 3, buzz for multiples of 5, fizzbuzz for multiples of 3 and five', function(){ + expect(factorial(5)).to.deep.equal(120) + }) +})