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

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

#2

Just remember some algebra. If they would tell you that the a is like double b minus c, how you would write this? a = 2 * b - c like that, right. Same is here:
fahrenheit = (whatever actions performed with celsius)

in your attempt you are changing celsius variable itself

#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.