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 The Solution

geometry.js:16 Uncaught ReferenceError: math is not defined at circle (geometry.js:16) at geometry.js:26

What am I missing?

function area (width,height) { return width*height; }

function volume (width,height,length) { return width*height*length; }

function circle (radius) { return math.PI * Math.pow(radius,2); }

function sphere(radius) { return (4/3) * math.PI * Math.pow(radius,3); }

console.log (area(5,22)); console.log (volume(4.5,12.5,17.4)); console.log (circle(7.2)); console.log (sphere(7.2));

1 Answer

Cameron Childres
Cameron Childres
11,817 Points

Hi Amy,

The built-in Math object begins with a capital letter. If you change both instances of "math.PI" to "Math.PI" the object will be referenced correctly and your code should run.

You can pinpoint this quickly from looking at the error:

Uncaught ReferenceError: math is not defined at circle (geometry.js:16) at geometry.js:26

This is saying math isn't defined, it doesn't reference anything. It's pointing to the circle function and saying the error occurred on line 16 of geometry.js, when called from line 26 of geometry.js.

Hope this clarifies things! Let me know if you need any additional help.