-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircle.js
More file actions
38 lines (33 loc) · 1.27 KB
/
circle.js
File metadata and controls
38 lines (33 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(function () {
"use strict";
// create a circle object
var circle = {
radius: 3,
getArea: function () {
// // TODO: complete this method
// // hint: area = pi * radius^2
// return; // TODO: return the proper value
return Math.PI * this.radius ** 2;
},
logInfo: function (doRounding) {
// TODO: complete this method.
// If doRounding is true, round the result to the nearest integer.
// Otherwise, output the complete value
console.log("Area of a circle with radius: " + this.radius + ", is: ");
console.log(doRounding ? Math.round(this.getArea()) : this.getArea());
}
};
// log info about the circle
console.log("Raw circle information");
circle.logInfo(false);
console.log("Circle information rounded to the nearest whole number");
circle.logInfo(true);
console.log("=======================================================");
// TODO: Change the radius of the circle to 5.
circle.radius = 5;
// log info about the circle
console.log("Raw circle information");
circle.logInfo(false);
console.log("Circle information rounded to the nearest whole number");
circle.logInfo(true);
})();