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

Why is there a "Uncaught SyntaxError: Unexpected identifier" on "geometry.js:52 " ?

// 1. Attach this file geometry.js to the index.html file

// 2. Create a function that calculates the area of a rectangle. // The function should accept the width and height as arguments // and return the area of that rectangle. // The area of a rectangle is the width * height

function areaOfRectangle (width,height) { var area = width * height return area }

// 3. Create a function that calculates the volume of a rectangular prism. // The function should accept the width, height and length as arguments // and return the volume of that rectangular prism. // The volume of a rectangular prism is the width * height * length

function volumeOfRectanglarprism (width, height, length) { var volume = width * height * length return volume }

// 4. Create a function that calculates the area of a circle. // The function should accept the radius of the circle as an argument // and return the area of that circle. // The area of a circle is the value of π * radius^2

function areaOfCircle (radius) { var areaofcircle = π * radius^2 return areaofcircle }

// 5. Create a function that calculates the volume of a sphere. // The function should accept the radius of the sphere as an argument // and return the volume. // The volume of a circle is: 4/3 * π * radius^3

function volumeOfCircle (radius) { var volumeofcircle = 4/3 * π * radius^3 return volumeofcircle }

// 6. Use console.log to test each function and output to the JavaScript console // Here are the values to test and the expected results // -- Area of rectangle that is 5 wide and 22 tall: 110 // -- Volume of a rectangular prism that is 4.5 x 12.5 x 17.4: 978.7499999999999 // -- Area of a circle that with a radius of 7.2: 162.8601631620949 // -- Volume of a spehere with a radius of 7.2: 1563.4575663561109

console.log areaOfRectangle (5,22); console.log volumeOfRectanglarprism (4.5, 12.5, 17.4); console.log areaofcircle (7.2); console.log volumeofcircle (7.2);

2 Answers

Your console.log statements need to include parentheses

console.log(areaOfRectangle (5,22));

instead of

console.log  areaOfRectangle (5,22);

I fixed that but now I have a "Uncaught ReferenceError: areaofCircle is not defined at geometry.js:54"

// 1. Attach this file geometry.js to the index.html file

// 2. Create a function that calculates the area of a rectangle. // The function should accept the width and height as arguments // and return the area of that rectangle. // The area of a rectangle is the width * height

function areaOfRectangle (width,height) { var area = width * height return area }

// 3. Create a function that calculates the volume of a rectangular prism. // The function should accept the width, height and length as arguments // and return the volume of that rectangular prism. // The volume of a rectangular prism is the width * height * length

function volumeOfRectanglarprism (width, height, length) { var volume = width * height * length return volume }

// 4. Create a function that calculates the area of a circle. // The function should accept the radius of the circle as an argument // and return the area of that circle. // The area of a circle is the value of π * radius^2

function areaOfCircle (radius) { var areaofCircle = π * radius^2 return areaofCircle }

// 5. Create a function that calculates the volume of a sphere. // The function should accept the radius of the sphere as an argument // and return the volume. // The volume of a circle is: 4/3 * π * radius^3

function volumeOfCircle (radius) { var volumeofCircle = 4/3 * π * radius^3 return volumeofCircle }

// 6. Use console.log to test each function and output to the JavaScript console // Here are the values to test and the expected results // -- Area of rectangle that is 5 wide and 22 tall: 110 // -- Volume of a rectangular prism that is 4.5 x 12.5 x 17.4: 978.7499999999999 // -- Area of a circle that with a radius of 7.2: 162.8601631620949 // -- Volume of a spehere with a radius of 7.2: 1563.4575663561109

console.log (areaOfRectangle (5,22)); console.log (volumeOfRectanglarprism (4.5, 12.5, 17.4)); console.log (areaofCircle (7.2)); console.log (volumeofCircle (7.2));

You defined it as areaOfCircle with an uppercase O. Same with volumeOfCircle.

I also ended up substituting 3.14 for π.