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

DeMarcus Rush
DeMarcus Rush
5,378 Points

Error with checker

I am entering the code var circumference = Math.pi(diameter) which appears to be right. I am lost on why it is not accepting it.

2 Answers

Math.PI is a constant, not a method, so you have to use it as you would use a variable. So, the circumference is the diameter multiplied by Pi.

Also, since JavaScript is case-sensitive, make sure you type both P and I as capital letters.

var circumference = Math.PI * diameter;
Michael Hulet
Michael Hulet
47,912 Points

The only think I immediately spot wrong with your code is that you don't use a semicolon at the end of your line

Semicolons are not always mandatory in JavaScript. They are good practice, though.

However, in this case, the lack of the semicolon isn't really what's causing the issue.