FreeCodeCamp.com - Basic JavaSript - Convert Celsius to Fahrenheit

Link:
https://www.freecodecamp.com/challenges/convert-celsius-to-fahrenheit#?solution=%0Afunction convertToF(celsius) {%0A var fahrenheit%3B%0A %2F%2F Only change code below this line%0A%0A fahrenheit %3D celsius * 9 %2F 5 %2B 32%3B %0A%0A %2F%2F Only change code above this line%0A return fahrenheit%3B%0A}%0A%0A%2F%2F Change the inputs below to test your code%0AconvertToF(30)%3B%0A

To test your learning, you will create a solution "from scratch". Place your code between the indicated lines and it will be tested against multiple test cases.
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 apply the algorithm to assign it the corresponding temperature in Fahrenheit.

Note
Don't worry too much about the function and return statements as they will be covered in future challenges. For now, only use operators that you have already learned.

Sollution:
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line

  fahrenheit = celsius * 9 / 5 + 32;  

  // Only change code above this line
  return fahrenheit;
}

// Change the inputs below to test your code
convertToF(30);

Komentáře

Populární příspěvky z tohoto blogu

FreeCodeCamp.com - Basic JavaSript - Passing Values to Functions with Arguments

FreeCodeCamp.com - Basic JavaSript - Word Blanks

FreeCodeCamp.com - Basic JavaSript - Understand String Immutability