Javascript Function Creation convert celsius to fahrenheit

Description

Javascript Function Creation convert celsius to fahrenheit


function toCentigrade(degFahren) {
    let degCent = 5 / 9 * (degFahren - 32);

    console.log(degFahren + " Fahrenheit is " +
                   degCent + " Celsius.<br/>");
}

function toFahrenheit(degCent) {
    let degFahren = 9 / 5 * degCent + 32;

    console.log(degCent + " Celsius is " +
                   degFahren + " Fahrenheit.<br/>");
}

function convert(converter, temperature) {
    converter(temperature);//w ww .j  av a  2  s. com
}

convert(toFahrenheit, 23);
convert(toCentigrade, 75);



PreviousNext

Related