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 JavaScript Foundations Numbers The Math Object

Problem with Math.pi

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 wrote;

var circumference = diameter * Math.Pi;

It says; "Bummer! Sorry! That's not correct. Remember, the circumference should be equal to the diameter times Pi."

Whats wrong in my code?

Carla Thomas
seal-mask
.a{fill-rule:evenodd;}techdegree
Carla Thomas
Front End Web Development Techdegree Student 16,039 Points

Hi Muhammad,

Not sure if quotations were added as part of your answer. Try editing your question and use the Markdown Cheatsheet so those who read your question will be able to see your mistake(s).

Carla

2 Answers

Carla Thomas
seal-mask
.a{fill-rule:evenodd;}techdegree
Carla Thomas
Front End Web Development Techdegree Student 16,039 Points

Quotations are not needed for the code.

Traditional math formula looks like this: circumference = (pi)(diameter) ....just use the two variables and Math.PI instead.

 var circumference = Math.PI * diameter;

Thanks a lot for pointing it out. I forget to capitalize the Pi. I am new at it and it will take a while getting used to the markdown.