Merge pull request #832 from Qo2770/master

[FEATURE] Add Kilometers/Hour to Miles/Hour conversion and reverse
This commit is contained in:
Angelos Chalaris
2018-10-16 20:24:41 +03:00
committed by GitHub
6 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,14 @@
### kmphToMph
Convert kilometers/hour to miles/hour.
Multiply the constant of proportionality with the argument.
```js
const kmphToMph = (kmph) => 0.621371192 * kmph;
```
```js
kmphToMph(10); // 16.09344000614692
kmphToMph(345.4); // 138.24264965280207
```

View File

@ -0,0 +1,14 @@
### mphToKmph
Convert miles/hour to kilometers/hour.
Multiply the constant of proportionality with the argument.
```js
const mphToKmph = (mph) => 1.6093440006146922 * mph;
```
```js
mphToKmph(10); // 16.09344000614692
mphToKmph(85.9); // 138.24264965280207
```

View File

@ -0,0 +1,2 @@
const kmphToMph = (kmph) => 0.621371192 * kmph;
module.exports = kmphToMph;

View File

@ -0,0 +1,9 @@
const expect = require('expect');
const kmphToMph = require('./kmphToMph.js');
test('kmphToMph is a Function', () => {
expect(kmphToMph).toBeInstanceOf(Function);
});
test('Returns mph from kph.', () => {
expect(kmphToMph(10)).toBe(6.21371192);
});

View File

@ -0,0 +1,2 @@
const mphToKmph = (mph) => 1.6093440006146922 * mph;
module.exports = mphToKmph;

View File

@ -0,0 +1,9 @@
const expect = require('expect');
const mphToKmph = require('./mphToKmph.js');
test('mphToKmph is a Function', () => {
expect(mphToKmph).toBeInstanceOf(Function);
});
test('Returns kph from mph.', () => {
expect(mphToKmph(10)).toBe(16.09344000614692);
});