Coding Challenge: Circumference and Area of a Circle

Let's write a program that will take the radius of a circle and return it's circumference and area.

Problem statement

Let’s play with the functions and try to calculate the circumference and area of a circle. Here are some hints for solving this exercise:

  • You can use the “2Πr2Πr” to compute circumference and “Πr2r^{2}” to compute the area of the circle.
  • The value of the number π (Pi) is obtained with Math.PI in JavaScript.
  • You might want to use the exponentiation operatorUse to raise a number to the power of an exponent. ** to perform computations.

Input

circumference(2);
circumference(12);

area(20);
area(4);

Expected output

12.566370614359172
75.39822368615503

1256.6370614359173
50.26548245743669

Coding exercise

Get hands-on with 1200+ tech skills courses.