Answer:
It is not entirely clear what your program is trying to achieve, but I embedded it inside some HTML to show you a working version.
- class methods in javascript don't require the 'function' keyword.
- to access class variables, always use the 'this' instance reference.
- when using class methods as event handlers, bind them to 'this'. This is a weird javascript quirk you want to check out.