mediator example in JavaScript