Miles to kilometers
In order to convert from miles to kilometers, you can use the conversion formula km = mi * 1.609344
.
代码实现
const milesToKm = miles => miles * 1.609344;
milesToKm(5); // ~8.04672
Kilometers to miles
Conversely, the conversion formula from kilometers to miles is mi = km * 0.621371
.
使用样例
const kmToMiles = km => km * 0.621371;
kmToMiles(8.1) // 5.0331051