# Basic Javascript - celsius to farenheit "Beginner gettin' brain fried" [Solved]

Basic Javascript - celsius to farenheit "Beginner gettin' brain fried" [Solved]
0.0 0

#3

Hi, welcome to coding !

Your conversion is correct, but your function is returning the value of the `fahrenheit` variable (which is undefined in this case).

There are many ways to go around this one. For one, you can change `return fahrenheit;` to `return celsius;`.

You can also add `fahrenheit = celsius;` after the first comment, then replace every `celsius` afterwards with `fahrenheit`.

``````fahrenheit = celsius;
fahrenheit *= 9;
fahrenheit /= 5;
fahrenheit += 32;

return fahrenheit;
``````

This too is nice (as it resembles the conversion formula, but step-by-step is a good start too!):
`fahrenheit = (9 / 5) * celsius + 32;`

#4

I just completed this so maybe I can give a hint as to how I figured this out.

I too was stumped with this one for a bit until I remembered that unlike normal text, Javascript is read from right to left. The formula (algorithm) they give you is for us to read i.e left to right not the computer. So you need to make the computer be able to read it correctly.

Hope this helps.

Katie

#5

Thanks very much for your help.

I started out with this

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

fahrenheit=(celsius*9/5)+32

// Only change code above this line
return fahrenheit;
}
// Change the inputs below to test your code
convertToF(0);

but that didnāt work or follow the form of the instructions weād been given so I tried thisā¦

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

celsius*=9;
celsius/=5;
celsius+=32;

// Only change code above this line
return fahrenheit;
}
// Change the inputs below to test your code
convertToF(0);

Still no luck. So I tried this ā¦

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

// Only change code above this line
return fahrenheit;
}

this ā¦

// Change the inputs below to test your code
convertToF(0);

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

// Only change code above this line
return fahrenheit;
}
// Change the inputs below to test your code
convertToF(0);

thisā¦

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

// Only change code above this line
return fahrenheit;
}
// Change the inputs below to test your code
convertToF(0);

thisā¦

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

fahrenheit*=9;
fahrenheit/=5;
fahrenheit+=32;

fahrenheit = celsius;

// Only change code above this line
return fahrenheit;
}
// Change the inputs below to test your code
convertToF(0);

And as you can probably tell ā¦ after Iād checked for typos ā¦ tried the variations again ā¦ went to stackoverflow ā¦ tried the variations again ā¦ I started to go just a little loopy.

#6

Ok this is probably a really silly point butā¦

on the first example you didnāt end it with a semi-colon, could that be it?

#7

Actually, semicolons are optional in JavaScript

#8

Just tried it with a semi-colon just in case. No luck.

Iām assuming Iām doing the correct procedure in terms of ā¦ I fill out the code and then place my cursor on the end of convertToF(0); press enter and expect the conversion to appear on the line below.

#9

change the 0 to a celsius temperature for exampe:

convertToF(25);

then run it, hopefully it will work.

#10

I pasted the first example in FCCās editor and it passed.

(this one)

``````function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

fahrenheit=(celsius*9/5)+32

// Only change code above this line
return fahrenheit;
}
// Change the inputs below to test your code
convertToF(0);
``````

#11

Thatās interesting. Maybe Iāve got the only Whereās Wally book that they forgot to put any Wallyās in.

Iāll try rebooting. If that doesnāt work Iāll go to bed. (1am in Australia)

Hey, this was my first ever experience of getting support from an online community and it was magnificent.

Thanks to all.

#12

You just need to press ārun testsā once youāve filled the code out, cursor doesnāt need to be on the end.

It should work, it did on mine.

#13

That was it. I canāt believe it. I thought because it said it would be tested against multiple cases ā¦ I was the one to test it against multiple cases ā¦ by changing the variable in the brackets each time and pressing enter.

You did it loud librarian.

Wooo Hooo!!!

#14

#15

Pretty funny really. I thought my car wouldnāt start 'cause of a problem in the engine but it was 'cause I was turning the key into the lighter socket.

Cheers.

#16

This is awesome! I would nominate this for @P1xtās forum quote of the day, but I am not @P1xt, so I canāt.

Btw, I am also in Australia (Melbourne), and from what I can tell, there are not too many of us on the forum - so please stick around so I have a timezone buddy

#18

Hey Jackson.

Iām a Melbournian also. Iāve just gotten into learning to code online in the last few months and Iām loving it. There is however a very particular type of brain inflammation that occurs when you come up against a barrier. Only seconds ago you were Zeus, manipulating the universe with a few taps on your magic button box, and the suddenly without warning you find yourself all alone in a little room like a hungry waif holding a can of baked beens but lacking a can opener. You try to come at it from as many different angles as you can think of but to no avail, and you know that if there was someone experienced beside you theyād just glance over and casually mutter something like āYou didnāt put a blip on your blopā, or āYouāre zoing doesnāt match your fazongā, and then with one simple adjustment, youād be off again cruising down the river of creative flow.

Last night was my first experience of turning to the forum for support and it was great. Quite strange. Asking strangers for help. But beautiful too. Hopefully, one day soon Iāll see someone calling for rescue, and Iāll be the one who can say "Have you tried ā¦ "

Cheers and no doubt Iāll see you in cyberspace

#19

I took the long way around ā look ma, no parenthesis!

var a = 9 / 5;
var b = 32;

fahrenheit = celsius * a + b;

#20
``````fahrenheit=(celsius*9/5)+32;
``````

#21

Iām also new to coding and got stumped on this one. Thanks for all the help!

#22

pture 1

Hi Fam, seems like i got the code right, but cant seem to go through the other challenges to submit it?

Thanks.

#23