Celsius to Fahrenheit

Tell us what’s happening:
so as I have looked at the problem I am at a loss. I understand that my input goes in the middle, so I
have that I also see that changing the convertToF() on the bottom will test what I have entered. I have even gotten two answers correct but I’m unclear as to how? I’ve tied looking elsewhere to figure it out for myself but I’m stuck please help.

Your code so far

function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line
function convertToF(celcius) {
  fahrenheit; = (-30 * 9/5 + 32);
  fahrenheit; = (-10 * 9/5 + 32);
  fahrenheit = (0 * 9/5 + 32);
  fahrenheit = (20 * 9/5 + 32);
  fahrenheit = (30 * 9/5 + 32);
  // Only change code above this line
  return fahrenheit;

// Change the inputs below to test your code

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8.

Link to the challenge:

What you might want to do is write a script that converts regardless of what you throw at it. So:

  1. We know that to convert from Celsius to Fahrenheit we need the temperature in Celsius times 9/5, plus 32.
  2. as a mathematical equasion this would be inFarenheit = inCelsius * 9 / 5 + 32
  3. now we wrap this equasion in a function, that is we literally put the equasion between the { and } of the function (in my example the variables are called inFarenheit and inCelsius but in the assignment they have different names)
  4. (already given) then the function returns the number of Farenheit
  5. (remember the variable has to have the same name that you used before i.e. you have to get the value from the same box you used to store it in otherwise there is nothing in the box because you didn’t put anything there. So if your variable is called duck, and you put the string “egg” in it, the string “egg” will only be in the variable duck, not in chicken, not in platypus etc.)

Thank so for the response Lukas I’m not sure I’m understanding so I’ll let you know what I tried based on your answer. So I Entered

fahrenheit = {
celsius: * 9/5 + 32;

Returned " SyntaxError: Unexpected token ‘*’. Expected a ‘:’ following the property.name ’ convertToF’.

fahrenheit { convertToF * 9/5 + 32}
Returned "SyntaxError: Unexpected token ‘token’.
At least with this I got one correct “convertToF(0)”

With that way you are trying to build a function within a function (if I understand all this). Remember, what the exercise wants you to do is to build a formula that does the conversion within the function that is provided,

In the snippets you are showing your close, but almost over thinking it.

1 Like

You can see it this way - the function is your worker (it is called convertToF in this example), your worker’s job is to unpack one package celsius, take what is inside of it, change it, pack it into another package farenheit and then give it back to you.

You have to talk to the worker if you want to get the job done, talking to the packages does nothing because, well, they are packages and not really interested in talking XD

1 Like

hahahaha, i feel so dumb… its literally like you said, it took me like 15 minute to figure out the problem by read and reread your reply to this thread…

all you need is to calm and read very carefully what your variable is
thank you so much xD

It just takes time. The brain can do incredible things. You will succeed, it’s just a matter of “when”, not “if”.

1 Like