console.log("The value of pi is: " + Math.PI);
You can also use the
Math.PI property in mathematical expressions, such as calculating the area of a circle:
let radius = 5; let area = Math.PI * (radius * radius); console.log("The area of a circle with radius " + radius + " is " + area);
In this example, we first declare a variable
radius with a value of 5. Then, we use the
Math.PI property in an expression to calculate the area of a circle with that radius, and finally, we log the result to the console.