Javascript Math PI

Introduction

The Math.PI property represents the ratio of the circumference of a circle to its diameter, approximately 3.14159.

The following function uses Math.PI to calculate the circumference of a circle.

function calculateCircumference(radius) {
  return Math.PI * (radius + radius);
}

let a = calculateCircumference(3);
console.log(a);/* w ww . j  a  v  a  2 s  .  c o m*/



PreviousNext

Related