JSFiddle - React, Tailwind, and code Playground

JavaScript

var Game = (function () {
  User = function () {
    var username;

    return {
      setUsername: function (newUsername) {
        username = newUsername;
      },
      getUsername: function () {
        return username;
      }
    }
  };

  Player = function () {
    score = 0;

    return {
      getScore: function () {
        return score;
      },
      play: function () {
        score = Math.round(Math.random()*100);
      }
    };
  };

  Player.prototype = new User();

  return {
    player1: new Player(), 
    player2: new Player()
  };
});

var game = new Game();

game.player1.setUsername('alex');
game.player2.setUsername('tony');

game.player1.play();
game.player2.play();

console.log(game.player1.getUsername()+': '+game.player1.getScore());
console.log(game.player2.getUsername()+': '+game.player2.getScore());