I must write a JavaScript function that calculates circle area by given radius. Print the area as it is calculated and then print it rounded to two decimal places.

Example: Input: 5

Output: 78.53981633974483 78.54

You can see the formula for calculating the area of a circle here:

And my code is:

function circleArea(radius) { let area = Math.PI * (radius * radius); console.log(area); console.log(Math.round(area*100)/100); } circleArea(5);

My code:

function circleA(r) { console.log(Math.PI * r * r); console.log(Math.round(Math.PI * r * r * 100) / 100); } circleA(5);

My code is:

function cA(rad) { let area = Math.PI * rad * rad; console.log(area); let areaRounded = Math.round(area * 100) / 100; console.log(areaRounded); } cA(5);

622 questions

979 answers

129 comments

53 users