Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Temperature Converter

Object-Oriented Programminghard

Course · Section 14: Object-Oriented Programming (OOP) With JavaScript · Lecture 226: ES6 Classes

Define a `Temperature` class storing Celsius with a `toF()` method, and implement `toFahrenheit(c)` returning the Fahrenheit value.

Sample tests

Input: toFahrenheit(0)
Output: 32
Input: toFahrenheit(100)
Output: 212

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Operator precedence: write c * 9 / 5 + 32 carefully.

Learning resources

  • MDN: Classes
Approach & explanation (try first)

The class wraps a Celsius value and converts to Fahrenheit with the standard formula.

Loading...
⌘/Ctrl + Enter

Run your code to see results.