how to build a rectangle using a constructor, it seems like I wrote everything, but where is the error.
function ready() { function Rectangle(w, h) { this.width = w; this.height = h; } Rectangle.prototype.width = function() { return this.width * 2; } Rectangle.prototype.height = function() { return this.height * 2; } var rectOne = new Rectangle(300, 200); var test = document.getElementById("test"); test.style.background = "red"; test.style.width = rectOne.width() + "px"; test.style.height = rectOne.height() + "px"; }; document.addEventListener("DOMContentLoaded", ready); <div id=test></div>