Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Temperature Conversion Module

A Closer Look at Functionseasy

Course · Section 10: A Closer Look at Functions · Lecture 34: Functions

Implement two functions that the test driver will call together: - `cToF(c)` converts Celsius to Fahrenheit. - `fToC(f)` converts Fahrenheit to Celsius. Formulas: F = C * 9/5 + 32 and C = (F - 32) * 5/9.

Examples

Input: cToF(0), cToF(100), fToC(32)
Output: [32, 212, 0]
0C is 32F, 100C is 212F, and 32F is 0C.

Sample tests

Input: cToF(0), cToF(100), fToC(32)
Output: [32,212,0]
Input: cToF(20), fToC(212)
Output: [68,100]

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Operator precedence: write the multiplication and division before adding 32.
Visualize this concept: call, apply, and bind →
Approach & explanation (try first)

Both conversion functions are exercised together by the driver. This mirrors interview problems where one task involves several cooperating functions.

Loading...
⌘/Ctrl + Enter

Run your code to see results.