Attempting to build an electron app. I have a Class called Rectangle and I want to have a method of the Class called changeColour() which I can call referencing an instance of the Rectangle Class, like this...
class Rectangle {
constructor(height, width) {
//draw a rectangle...
return rectangle;
}
changeColour() {
//do some colour changing...
return something;
}
}
module.exports = Rectangle;
In a main.js or main.html I wish to make instances of this Class and to call the method changeColour()
<script>
const Rectangle = require('./classes/Rectangle.js');
const rectangle_1 = new Rectangle(100, 600);
var elem = document.getElementById('mainDiv');
elem.appendChild(rectangle_1.rectangle_instance);
rectangle_1.changeColour();
</script>
```
The instance of Rectangle works fine, but the calling of its method changeColour() throws an error ...
Uncaught TypeError: rectangle_1.changeColour is not a function.
Can anyone help me with solving this error please?
enter code here