title: Accessing/Calling a class method from another class in mediator pattern javascript
body: <pre><code>class Customer {
      constructor(name) {
          this.name = name;
      }
      send(amount, to) {
          new GooglePay().send(amount, this, to);
      }
      receive(amount, from) {
          console.log(`Payment of ${amount} from ${from} to ${this.name} is succesful`);
      }
  }
  </code></pre>
  
  <p>the problem is based on mediator pattern.
  so above i have defined my customer who can send and receive money. So I have built a class called GooglePay which mediates transaction between customers.
  Customer have send function through which they can send money, it takes 2 arguments (amount ,to)</p>
  
  <p>The function should actually then invoke or be received by the GooglePay instance which then sends the amount to the receiver after checking if the receiver has registered</p>
  
  <pre><code>class GooglePay {
      constructor() {
          this.customerBase = [];
      }
      register(name) {
          this.customerBase.push(name);
          return this;
      }
      send(amount, from, to) {
          if (this.customerBase.filter(cust =&gt; cust === to)) {
              to.receive(amount, from);
          } else {
              console.log('This customer does not exist');
          }
      }
  }
  
  </code></pre>
  
  <p>Kindly help me out, I'm stuck and I dont understand how i can access methods of other classes from a class.</p>