Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -89,6 +93,7 @@ module.exports = {
fahrenheit2Celcius: fahrenheit2Celcius,
power: power,
nOfFibonacci: nOfFibonacci,
inchesToCm: inchesToCm,
shuffleArray: shuffleArray,
iThink: iThink
}
7 changes: 6 additions & 1 deletion sketch.test.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -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.");
})
Expand Down