From ca0de2deba1906125e567b7975bf0108991eb342 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Thu, 16 Apr 2020 11:09:37 +0300 Subject: [PATCH] Remove squareSum --- snippets_archive/squareSum.md | 16 ---------------- test/squareSum.test.js | 16 ---------------- 2 files changed, 32 deletions(-) delete mode 100644 snippets_archive/squareSum.md delete mode 100644 test/squareSum.test.js diff --git a/snippets_archive/squareSum.md b/snippets_archive/squareSum.md deleted file mode 100644 index af17a6c2e..000000000 --- a/snippets_archive/squareSum.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: squareSum -tags: math,beginner ---- - -Squares each number in an array and then sums the results together. - -Use `Array.prototype.reduce()` in combination with `Math.pow()` to iterate over numbers and sum their squares into an accumulator. - -```js -const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0); -``` - -```js -squareSum(1, 2, 2); // 9 -``` \ No newline at end of file diff --git a/test/squareSum.test.js b/test/squareSum.test.js deleted file mode 100644 index 8219f52f4..000000000 --- a/test/squareSum.test.js +++ /dev/null @@ -1,16 +0,0 @@ -const {squareSum} = require('./_30s.js'); - -test('squareSum is a Function', () => { - expect(squareSum).toBeInstanceOf(Function); -}); -test('squareSum returns the proper result', () => { - expect(squareSum(2, 3, 4)).toBe(29); -}); - -test('works with negative numbers', () => { - expect(squareSum(-2, 3, -4)).toBe(29); -}); - -test('NaN when parameters have text', () => { - expect(squareSum(-2, 3, -4, 'text')).toBe(NaN); -});