Skip to content

unioncollege-webtech/temperature-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Temperature Converter

Join the chat at https://gitter.im/unioncollege-webtech/temperature-converter

Define functions to convert between celsius and fahrenheit.

Description

Create a file called "temperature.js", which does the following:

  1. Create a new variable Temperature, which is an Object with two properties:
  2. toFahrenheit: A Function which takes one argument: celsius (a number), calculates the equivalent value in Fahrenheit, and returns the Fahrenheit value.
  3. toCelsius: A Function which takes one argument: fahrenheit (a number), calculates the equivalent value in Celsius, and returns the Celsius value.

The formula for converting Celsius to Fahrenheit is: F = C × (9⁄5) + 32.
The reverse of that is: C = (F - 32) × (5⁄9) 2. Create a new variable tempToday, and set the value to 82. This is today’s temperature in Fahrenheit. 3. Create a new variable tempInCelsius, and set its value equal to the Celsius equivalent, rounded to the nearest whole number. The Celsius equivalent should be calculated by calling the toCelsius function property on Temperature, passing it tempToday. Round the result by using the Math.round() function. 4. Create a new variable, message, and set its value equal to a string that is in this form: “Today’s temperature is °F, which is °C.” 5. Log message to the console.

Completing and submitting the assignment

You are also welcome commit, push, and create a pull request before you’ve completed your solution. You can ask questions or request feedback there in your pull request. Just mention @barberboy in your comments to get my attention.

Resources

Objects Functions

About

Define functions to convert between celsius and fahrenheit

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published