JavaScript - algorithm to convert from Celsius to Fahrenheit

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9 / 5, plus 32. You are given a variable celsius representing a temperature in Celsius. Use the variable Fahrenheit already defined and assign it to the Fahrenheit temperature equivalent to the given Celsius temperature. Use the algorithm mentioned above to help convert the Celsius temperature to Fahrenheit.

Solution Basic approach

console = { 
    log: print,
    warn: print,
    error: print
function convertToF(celsius) {
    var fahrenheit = celsius * (9 / 5) + 32;
    if (typeof fahrenheit !== "undefined") {
        return fahrenheit;
    } else {
        return "fahrenheit not defined";



download android app

Popular javascript Examples is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube