function functionName(parameter1, parameter2){
// function's code
}
let radius1 = 3;
let radius2 = 7;
let radius3 = 12;
// etc, etc, etc. ....
let radius20 = 15;
let radii = [3, 7, 12, 5, 9, 42, 8, 60, 45, 21, 6, 9, 14, 27, 84, 32, 52, 37, 36, 15];
let circumference1 = 2 * Math.PI * radius1; // or, with use of an array, var circumference1 = 2*Math.PI*radiuses[0];
let circumference2 = 2 * Math.PI * radius2; // or, with use of an array, var circumference2 = 2*Math.PI*radiuses[1];
let circumference3 = 2 * Math.PI * radius3; // or, with use of an array, var circumference3 = 2*Math.PI*radiuses[2];
let circumference20 = 2 * Math.PI * radius20; // or, with use of an array, var circumference20 = 2*Math.PI*radiuses[19];
console.log(circumference1);
console.log(circumference2);
console.log(circumference3);
console.log(circumference20);
function circumferenceCalculator(radius){
// ...
}
function circumferenceCalculator(radius) {
console.log("My function found that the circumference of a circle with a radius of "
+ radius + " is " + 2 * Math.PI * radius);
}
// passing in the radius value directly for the first circle
circumferenceCalculator(3);
// passing in the variable storing the radius value for the
// second circle
circumferenceCalculator(radius2);
// passing in the element in the radiuses array that stores the
// radius value for the third circle (remember that it is
// radiuses[2] because the index of an array begins at
// 0 rather than 1.)
circumferenceCalculator(radiuses[2]);