areaOfRing-- a value-returning function that accepts more than one argument
// Program File: areaOfRing2.js
//function definition
function areaOfRing(R, r){
return Math.PI * (R ** 2 - r ** 2);
}
//test the function
//declare the input and output variables
let outerDiskRadius, innerDiskRadius;
let area1, area2;
outerDiskRadius = 10;
innerDiskRadius = 8;
area1 = areaOfRing(outerDiskRadius, innerDiskRadius);
outerDiskRadius = 10;
innerDiskRadius = 8;
area2 = areaOfRing(outerDiskRadius, innerDiskRadius);
//output results (uses backticks)
console.log(`area1 = ${area1}
area2 = ${area2}`);
alert(`area1 = ${area1}
area2 = ${area2}`);
//this is better: echo the inputs
console.log("outerDiskRadius = " + outerDiskRadius + " innerDiskRadius = " + innerDiskRadius +" area = " + area1);
alert("outerDiskRadius = " + outerDiskRadius + " innerDiskRadius = " + innerDiskRadius +" area = " + area1);