From fb9b714b8024813737bbf86b02437ae49e72eac2 Mon Sep 17 00:00:00 2001 From: Ilana Bonder Date: Tue, 2 Oct 2018 11:32:51 -0400 Subject: [PATCH 1/3] adding inches to cm function --- sketch.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sketch.js b/sketch.js index 7476282..9057d8c 100644 --- a/sketch.js +++ b/sketch.js @@ -48,6 +48,10 @@ function nOfFibonacci(x) { return (!n || n < 1) ? -1 : (n < 3 ? 1 : (nOfFibonacci(n-1) + nOfFibonacci(n-2))); } +function inchesToCm(x){ + return(x*2.54); +} + // shuffle an array using the Fisher-Yates algorithm // retyped from https://stackoverflow.com/a/6274398 function shuffleArray(array) { @@ -89,6 +93,7 @@ module.exports = { fahrenheit2Celcius: fahrenheit2Celcius, power: power, nOfFibonacci: nOfFibonacci, + inchesToCm: inchesToCm, shuffleArray: shuffleArray, iThink: iThink } From a49350a6f66469eaac6000b77a4416d0669c0664 Mon Sep 17 00:00:00 2001 From: Ilana Bonder Date: Tue, 2 Oct 2018 11:35:30 -0400 Subject: [PATCH 2/3] adding unit test inches to cm --- sketch.test.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sketch.test.js b/sketch.test.js index 266c79e..2356bb1 100644 --- a/sketch.test.js +++ b/sketch.test.js @@ -1,4 +1,4 @@ -const { sum, sub, prod, digital_root, sum42, sayHelloTo, anomalyCode, fahrenheit2Celcius, power, nOfFibonacci, shuffleArray, iThink } = require('./sketch'); +const { sum, sub, prod, digital_root, sum42, sayHelloTo, anomalyCode, fahrenheit2Celcius, power, nOfFibonacci, inchesToCm, shuffleArray, iThink } = require('./sketch'); const fs = require("fs"); const path = require("path"); @@ -118,6 +118,11 @@ test('the 20th number of fibonacci should be 6765', () => { expect(nOfFibonacci(20)).toBe(6765); }) +// inchesToCm +test('testing inches to cm', () => { + expect(inchesToCm(10)).toBe(25.4); +}) + test('I think...', () => { expect(iThink("tests are annoying", "I appreciate them")).toBe("I think tests are annoying but I appreciate them."); }) From 084adf1ab319d8297e398bfcb071473f85156ed3 Mon Sep 17 00:00:00 2001 From: Daniel Shiffman Date: Tue, 2 Oct 2018 14:41:30 -0400 Subject: [PATCH 3/3] Update sketch.js --- sketch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sketch.js b/sketch.js index 9057d8c..84d7593 100644 --- a/sketch.js +++ b/sketch.js @@ -33,7 +33,7 @@ function anomalyCode(x) { function fahrenheit2Celcius(F) { - return (F - 32) * 5 / 9; + return (F - 32) * 6 / 9; } function anomalyCode(x) { return '5' + x - x;