I am new to Javascript

i need a little help in regards to this code.
How does the result get to 32 and 392. what is the magic behind this

// Write a function called convertToFahrenheit which takes a single
// parameter which is the temperature in degrees Celsius. The function
// should return the corresponding temperature in degrees Fahrenheit.

// Write your code here

let freezing = convertToFahrenheit(0);
console.log(freezing); // should print 32

let ovenTemp = convertToFahrenheit(200);
console.log(ovenTemp); // should print 392

Please post a link to the challenge.

I recall the challenge description had a formula for how the values are converted.

Thank you for your reply, Here is the link to the challenge

If you search google you will get the formula

Thank you, i understand how we arrived at 32 but arriving at 392 is the issue

Ah I see. That looks wrong.

I didn’t see the requirement in the link you provided.
Is your code failing some test?

When i run it on vscode it arrives at 32 and 200. Notice how the function in freezing is (0) and the function in ovenTemp is (200) after running the code it arrives at 32 for freezing and 392 as ovenTemp

My thinking was ovenTemp should be 200 given we are converting fahrenheit to celsius using its formula which will result to 0

Yeah that’s correct. The answer should be 392 since the question is only asking you to return the temp in degrees Fahrenheit.

Wow thanks, do i have to do any calculations to get the result 392?

You have to use the reverse formula (Celsius to Fahrenheit.)
Just google the formula.

One formula would do. If you can get 32 when the argument is 0 then it should be correct.

You can paste the function you wrote so we can have a look for you.

@kingvellz yes hbar1st is correct, to work out “Fahrenheit to Celsius”, then you need the reverse formula.

sorry i went offline. when i convert the opposite (Celsius to Fahrenheit) the result is 32. what calculation are we doing to get 392 using the celsius to fahrenheit result

it should be the same exact calculation. If your code is not working, show it to us.


The code is correct but i am wondering what calculation was done to arrive at 392 after using the celsius to fahrenheit conversion

have pasted the function, can you pls help check it out. if we using the celsius to fahrenheit conversion, how do we arrive at 392 given the result of celsius to fahrenheit is 32

It is only 32 when you pass in 0 for tempc. When you pass in 200 for tempc then it is 392. Each function call is completely separate from the others.

Okay thank you very much

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.