diff --git a/sketch.js b/sketch.js index 7476282..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; @@ -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 } 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."); })