We have this task:
You are given a variable celsius
representing a temperature in Celsius. Use the variable fahrenheit
already defined and assign it the Fahrenheit temperature equivalent to the given Celsius temperature. Use the formula mentioned above to help convert the Celsius temperature to Fahrenheit.
I solved it with this:
function convertToF(celsius) {
let fahrenheit = celsius * 9 / 5 + 32;
return fahrenheit;
}
convertToF(30);
But I guess, if we are tlaking in general, I could code similar function without any variables(like below)? What’s the best practice?
function convertToF(celsius) {
return celsius * 9 / 5 + 32;
}
convertToF(30);