JSFiddle - React, Tailwind, and code Playground
JavaScript
function Sphere(radius) {
this.radius = radius;
}
Sphere.prototype.pi = 3.14;
Sphere.prototype.volume = function() {
return Math.pow(this.pi, 3) * 3/4 * this.radius;
};
var football = new Sphere(10);
document.body.innerHTML += "<p>Volume: " + football.volume() + "</p>";
Sphere.prototype.pi = Math.PI;
document.body.innerHTML += "<p>Accurate volume: " + football.volume() + "</p>";