odin-default-js-exercises/07_tempConversion
Sudeep Sharma 06d0c179e7 modified: 01_helloWorld/helloWorld.js
modified:   02_repeatString/repeatString.js
modified:   02_repeatString/repeatString.spec.js
modified:   03_reverseString/reverseString.js
modified:   03_reverseString/reverseString.spec.js
modified:   04_removeFromArray/removeFromArray.js
modified:   04_removeFromArray/removeFromArray.spec.js
modified:   05_sumAll/sumAll.js
modified:   05_sumAll/sumAll.spec.js
modified:   06_leapYears/README.md
modified:   06_leapYears/leapYears.js
modified:   06_leapYears/leapYears.spec.js
modified:   07_tempConversion/README.md
modified:   07_tempConversion/tempConversion.js
modified:   07_tempConversion/tempConversion.spec.js
2022-10-18 12:13:00 +05:45
..
README.md modified: 01_helloWorld/helloWorld.js 2022-10-18 12:13:00 +05:45
tempConversion.js modified: 01_helloWorld/helloWorld.js 2022-10-18 12:13:00 +05:45
tempConversion.spec.js modified: 01_helloWorld/helloWorld.js 2022-10-18 12:13:00 +05:45

README.md

Exercise 07 - tempConversion

Write two functions that convert temperatures from Fahrenheit to Celsius, and vice versa:

ftoc(32) // fahrenheit to celsius, should return 0

ctof(0) // celsius to fahrenheit, should return 32

Because we are human, we want the result temperature to be rounded to one decimal place: i.e., ftoc(100) should return 37.8 and not 37.77777777777778.

This exercise asks you to create more than one function so the module.exports section of the spec file looks a little different this time. Nothing to worry about, we're just packaging both functions into a single object to be exported.

Hints

  • You can find the relevant formulae on Wikipedia.

  • Try to find by yourself on the Internet how to round a number to 1 decimal place in JavaScript. If you struggle, have a look here.