Skip to content
This repository was archived by the owner on Feb 20, 2019. It is now read-only.

Commit a444bab

Browse files
kam773Kent C. Dodds
authored andcommitted
feat(temperatureConvert): add function (#204)
* WIP: problem with test * WIP: problem with test Closes #203
1 parent f9b0652 commit a444bab

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import debounce from './debounce'
7474
import curry from './curry'
7575
import textJustification from './textJustification'
7676
import removeProperty from './removeProperty'
77+
import temperatureConverter from './temperatureConverter'
7778

7879
export {
7980
reverseArrayInPlace,
@@ -152,4 +153,5 @@ export {
152153
textJustification,
153154
removeProperty,
154155
dec2hex,
156+
temperatureConverter,
155157
}

src/temperatureConverter.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default temperatureConverter
2+
/**
3+
* Original Source: https://stackoverflow.com/questions/15122347/
4+
*
5+
* This function gets temperature in fahrenheit and converts it into celsius
6+
*
7+
* @param {Number} fahrenheit - Temperature in fahrenheit
8+
* @return {Number} - Temperature in celsius
9+
*/
10+
function temperatureConverter(fahrenheit) {
11+
const celsius = (fahrenheit - 32) * 5 / 9
12+
return celsius
13+
}

test/temperatureConverter.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import test from 'ava'
2+
import {temperatureConverter} from '../src'
3+
4+
test('converts temperature', t => {
5+
const number = 78
6+
const expected = (number - 32) * 5/9
7+
const actual = temperatureConverter(number)
8+
t.is(actual, expected)
9+
10+
})

0 commit comments

Comments
 (0)