Why is this wrong?

Why is this wrong?
0

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

(celsius*9/5)+32;
// Only change code above this line
return fahrenheit;
}

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

``````

and this right `(celsius*9/5))+32;`

stupid question but why the second closing bracket?

#2

Can you post the full code? Because the second bracket really shouldn’t be there, in fact it should be giving you an error. Or better yet, a link to your codepen?

#3

This is a challenge in the basic javascript section called Convert Celsius to Fahrenheit

I couldn’t pass it with my answer, and the hint gave the answer with the second closing bracket. I’m just trying to understand why the second bracket is there. I feel really dumb lol.

#4

You forgot to assign the expression to fahrenheit like `fahrenheit = (celsius*9/5)+32`; Putting it there alone just calculates a value, it won’t show it or save it anywhere.

Edit: The solution is written like this `(celsius * (9/5)) + 32` because by grouping operations you can force the order they will happen (although it’s unnecessary in this particular case) and it also helps with code readability, it doesn’t add functionality (again, in this particular case). You kind of confused me because you forgot one parenthesis in your first post and I may have answered a different question originally

#5

I think its because it orders the operations like this,

If you write:
(celsius 9/5)+32;
It will calculate
Celsius
5= X Then X/5= Y Then Y + 32 = Answer

However the second set of brackets instructs it to do whats in the brackets first.
So:
(celsius (9/5))+32;
Will calculate
9/5 = X And Then Celsius
X = Y Then Y+32= Output

Although I am a noob so could be wrong, but I think thats it. Maybe someone smarter than me can confirm/Correct