A "House" class is created with a constructor function that collects the width, height, and color of the house.
The "House" class has two methods:
An object "house1" is created with its properties and the color property, the dimensions and the area of the house are displayed on the screen.
xxxxxxxxxx
<p id="show_houses"></p>
<script>
class House {
constructor(width, height, color) {
this.width = width;
this.height = height;
this.color = color;
}
getArea(){
return this.width*this.height;
}
dimensions(x, y, z){
return x*y*z;
}
}
const house1 = new House(40, 50, 'white');
document.getElementById("show_houses").innerHTML=
"The "+house1.color+" house has the following dimensions: "+house1.dimensions(50,100,60)+" area: "+house1.getArea();
</script>
Interesting Articles