Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Numbers - The Math Operator (Code Challenge)
I am really struggling with Math Operator (https://teamtreehouse.com/library/the-math-object) code challenge.
Here's the question
Create a variable named "circumference" and assign the correct value to it by using the "diameter" variable and Math.PI. See the comment in the script for more information.
Any advice or code snippets would be greatly appreciated!
Do not get frustrated. Keep calm my friend. Math.PI is a method that stores the number pi(3.14.......). And the diameter has already been created in the challenge. The formula for Circumference is:
diameter x PI
And so we use this formula to formulate our code. Like so:
var circumference = diameter * Math.PI;
Hope this helped. :)
Hey Guled A (sweet profile pic btw)
Thank you very much for your help and it worked a real treat. I get it now, it's amazing what an awesome community of fellow Treehousers and a very strong coffee will do!
Thanks again for your prompt help!
scott duke5,033 Points
Wow.! I was trying
var circumference = diameter * Math.PI();
Because diameter is a floating point number. started getting scared, when I tried that, and it did not work. I finally passed because of your answer, but I need to keep going over this and also dive into bookmarks to make sure I totally get this. Don't feel confident, yet. I don't know if I would have thought to remove the parenthesis from the end of the constant Math.PI :-( */ How did you know to not use the parenthesis? I need to think different, if I am going to really get this.I apologize in advance for any errors in my markdown... I'm so tired. I just wanted to complete this before I even attempted sleep. lol  I can't even get markdown working.
scott duke5,033 Points
Thanks, Guled A! Plowing through, I gain a little bit of confidence each time. I love Treehouse and how much I am learning here!