JSFiddle - React, Tailwind, and code Playground

by Erwin Bochnia

JavaScript

function init(){
	//Run
  let theatre1 = new Theatre();
  let theatre2 = new Theatre();

  let person1 = new Developer("jan","kowalski","JavaScript")
  person1.email = "test@p.pl"  
  person1.displayCompetency();

  theatre1.placePerson(person1);
  theatre1.placePerson(new Person("kacper","kowalski"));
  theatre1.placePerson(new Person("grzegorz","kowalski"));
  theatre1.placePerson(new Person("aneta","kowalska"));

  theatre2.placePerson(new Person("Aneta","Kowalska"));

  theatre1.greetAllClients();
}
//Classes
var Theatre = (function() {
  "use strict";
  var priv = new WeakMap();
  var _ = function(instance) {return priv.get(instance);};

  class TheatreClass{
    constructor(){
      //prywatne wlasciwosci
      var privateMembers = {
        seats : []
      };   
      priv.set(this, privateMembers);
      //publiczne wlasciwosci
      this.maxSize = 3;
    }
    //metody 
    placePerson(person) {
      if(!this.isSoldOut()){
        _(this).seats.push(person);
      }else{
        console.info("Wyprzedano wszystkie bilety!");
      }
    }
    countOccupiedSeats(){
      return _(this).seats.length;
    }
    isSoldOut() {
      return _(this).seats.length >= this.maxSize;
    }
    countFreeSeats() {
      return this.maxSize - _(this).seats.length;
    }
    greets(person){
      var greeting = "Dzien dobry, ";
      function displayGreeting() {
        console.info(greeting + " " + person.fullName);
        person.greets();
      }
      displayGreeting();
    }
    greetAllClients(){
      if (this.countOccupiedSeats() === 0) return console.error("Nie ma nikogo na widowni"); 
      for(let x =0;x <= _(this).seats.length -1 ;x++){
        this.greets(_(this).seats[x]);
      } 
    }
    }
    return TheatreClass;
  }
());

var Person = (function (){
  "use strict";
  var priv = new WeakMap();
  var _ = function(instance) {return priv.get(instance);};
  class PersonClass {
  constructor(name,surname){
    var privateMembers = {email:""};
   ...