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

Uche Onuekwusi
Uche Onuekwusi
18,070 Points

Please help me out, it is showing NAN in my console element, i have no idea

function areacircle (radius) {

return Math.PI * Math.pow(radius^2 );

}
console.log(areacircle(7.2) );

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I believe you've confused one of the comments shown in this video with the code. When writing out with paper and pencil we often denote a power with the ^ sign. But in the Math.pow function, we send in the first number and raise it to a power of another number. We do this by separating them with a comma.

Take a look again at 3:01 of the video.

If I simply replace the ^ with a , your code runs just fine!

Math.pow(radius,2)

Hope this helps! :sparkles:

Abdullah Alosaimi
PLUS
Abdullah Alosaimi
Courses Plus Student 2,280 Points

You are using the carrot sign. To use the Math.pow() method you send the base and the exponent separated by a comma (base, exponent).

function areacircle (radius){

return Math.PI * Math.pow(radius, 2);

}
console.log(areacircle(7.2));

Good luck Uche!

Everton Carneiro
Everton Carneiro
15,994 Points

Another way of doing this is using a double star: return Math.PI * radius**2;