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! While you're at it, check out some resources Treehouse students have shared here.

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

JavaScript

Create variable circumference

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.

I am creating the variable by using var circumference = Math.PI(diamter); within the <script>

but it still is saying Bummer! No variable named "circumference" has been defined. Make sure to declare the variable like: var circumference =...

3 Answers

Hey matthew winters,

The reason the circumference variable was not defined properly is because of a JS error in your statement.

var circumference = Math.PI(diamter);

You seem to be using Math.PI as a function and passing it the "diamter" (seems to be misspelled) variable. But Math.PI is just a constant and can't be called like a function so your statement causes an error.

You'll want to multiply Math.PI times the diameter variable and assign that result to the circumference variable.

Thanks!

I am stuck on this one as well. I don't get it, so frustrating. What am I doing wrong there. 30mins on this question.

var circumference = Math.PI() * diameter;

Hi Brandon Heng. I'm sorry you're having trouble! The Math object has properties and methods. The methods are called using parenthesis () but the properties are accessed without the parenthesis. PI is a property so it is accessed without the parenthesis. Just remove the parenthesis and you should be good-to-go!

Here it you need to do: var circumference = Math.PI * diameter;