Merge pull request #832 from Qo2770/master
[FEATURE] Add Kilometers/Hour to Miles/Hour conversion and reverse
This commit is contained in:
14
snippets_archive/kmphToMph.md
Normal file
14
snippets_archive/kmphToMph.md
Normal 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
|
||||||
|
```
|
||||||
14
snippets_archive/mphToKmph.md
Normal file
14
snippets_archive/mphToKmph.md
Normal 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
|
||||||
|
```
|
||||||
2
test/kmphToMph/kmphToMph.js
Normal file
2
test/kmphToMph/kmphToMph.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const kmphToMph = (kmph) => 0.621371192 * kmph;
|
||||||
|
module.exports = kmphToMph;
|
||||||
9
test/kmphToMph/kmphToMph.test.js
Normal file
9
test/kmphToMph/kmphToMph.test.js
Normal 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);
|
||||||
|
});
|
||||||
2
test/mphToKmph/mphToKmph.js
Normal file
2
test/mphToKmph/mphToKmph.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const mphToKmph = (mph) => 1.6093440006146922 * mph;
|
||||||
|
module.exports = mphToKmph;
|
||||||
9
test/mphToKmph/mphToKmph.test.js
Normal file
9
test/mphToKmph/mphToKmph.test.js
Normal 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);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user