The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times
9/5
, plus32
.You are given a variable
celsius
representing a temperature in Celsius. Use the variablefahrenheit
already defined and assign it the Fahrenheit temperature equivalent to the given Celsius temperature. Use the algorithm mentioned above to help convert the Celsius temperature to Fahrenheit.
function convertToF(celsius) {
let fahrenheit;
return fahrenheit;
}
convertToF(30);
- Answer:
function convertToF(celsius) {
let fahrenheit = celsius * (9 / 5) + 32;
return fahrenheit;
}
convertToF(30);
convertToF(30) should return a value of 86
Top comments (0)