Files
odin-javascript-exercises/07_tempConversion/README.md
T

18 lines
990 B
Markdown
Raw Normal View History

2021-03-03 15:13:24 +13:00
# Exercise 07 - tempConversion
2017-08-25 10:27:07 -05:00
2018-06-08 23:14:20 -04:00
Write two functions that convert temperatures from Fahrenheit to Celsius, and vice versa:
2017-08-25 10:29:32 -05:00
```
2022-11-12 20:59:52 +01:00
convertToCelsius(32) // fahrenheit to celsius, should return 0
2017-08-25 10:29:32 -05:00
2022-11-12 20:59:52 +01:00
convertToFahrenheit(0) // celsius to fahrenheit, should return 32
2017-08-25 10:29:32 -05:00
```
2022-11-12 20:59:52 +01:00
Because we are human, we want the result temperature to be rounded to one decimal place: i.e., `convertToCelsius(100)` should return `37.8` and not `37.77777777777778`.
2018-06-08 23:14:20 -04:00
This exercise asks you to create more than one function so the `module.exports` section of the main javascript file looks a little different this time. Nothing to worry about, we're just packaging both functions into a single object to be exported.
2017-08-25 10:27:07 -05:00
2018-06-08 23:20:59 -04:00
## Hints
2018-06-08 23:14:20 -04:00
- You can find the relevant formulae on [Wikipedia](https://en.wikipedia.org/wiki/Conversion_of_units_of_temperature).
- 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](https://stackoverflow.com/q/7342957/5433628).