-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses.js
More file actions
24 lines (18 loc) · 666 Bytes
/
classes.js
File metadata and controls
24 lines (18 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// 1. Copy and paste your prototype in here and refactor into class syntax.
class CuboidMakerClass {
constructor(attr) {
this.length = attr.length;
this.width = attr.width;
this.height = attr.height;
}
volume() {
return this.width * this.length * this.height;
}
surfaceArea() {
return 2 * (this.length * this.width + this.length * this.height + this.width * this.height);
}
}
cuboid = new CuboidMakerClass({length: 4, width: 5, height: 5});
// Test your volume and surfaceArea methods by uncommenting the logs below:
console.log(cuboid.volume()); // 100
console.log(cuboid.surfaceArea()); // 130