2019-11-21 03:05:32 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
function feetInchesToCm(feet, inches) {
|
|
|
|
return Math.round((Number(feet) * 30.48) + (Number(inches) * 2.54));
|
|
|
|
}
|
|
|
|
|
2019-11-28 04:36:22 +00:00
|
|
|
function cmToFeetInches(centimeters) {
|
|
|
|
const feet = Math.floor(centimeters / 30.48);
|
|
|
|
const inches = Math.round((centimeters / 2.54) % (feet * 12));
|
|
|
|
|
|
|
|
return { feet, inches };
|
|
|
|
}
|
|
|
|
|
2019-11-21 03:05:32 +00:00
|
|
|
function heightToCm(height) {
|
|
|
|
const [feet, inches] = height.match(/\d+/g);
|
|
|
|
|
|
|
|
return feetInchesToCm(feet, inches);
|
|
|
|
}
|
|
|
|
|
|
|
|
function lbsToKg(lbs) {
|
|
|
|
const pounds = lbs.toString().match(/\d+/)[0];
|
|
|
|
|
|
|
|
return Math.round(Number(pounds) * 0.453592);
|
|
|
|
}
|
|
|
|
|
2019-11-28 04:36:22 +00:00
|
|
|
function kgToLbs(kgs) {
|
|
|
|
const kilos = kgs.toString().match(/\d+/)[0];
|
|
|
|
|
|
|
|
return Math.round(Number(kilos) / 0.453592);
|
|
|
|
}
|
|
|
|
|
2019-11-21 03:05:32 +00:00
|
|
|
module.exports = {
|
2019-11-28 04:36:22 +00:00
|
|
|
cmToFeetInches,
|
2019-11-21 03:05:32 +00:00
|
|
|
feetInchesToCm,
|
|
|
|
heightToCm,
|
|
|
|
lbsToKg,
|
2019-11-28 04:36:22 +00:00
|
|
|
kgToLbs,
|
2019-11-21 03:05:32 +00:00
|
|
|
};
|