'use strict';

function inchesToCm(inches) {
    return Math.round(Number(inches) * 2.54);
}

function feetInchesToCm(feet, inches) {
    return Math.round((Number(feet) * 30.48) + (Number(inches) * 2.54));
}

function cmToFeetInches(centimeters) {
    const feet = Math.floor(centimeters / 30.48);
    const inches = Math.round((centimeters / 2.54) % (feet * 12));

    return { feet, inches };
}

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);
}

function kgToLbs(kgs) {
    const kilos = kgs.toString().match(/\d+/)[0];

    return Math.round(Number(kilos) / 0.453592);
}

module.exports = {
    cmToFeetInches,
    feetInchesToCm,
    heightToCm,
    inchesToCm,
    lbsToKg,
    kgToLbs,
};
