function game(name, genre, year, players) {
    this.name = name;
    this.genre = genre;
    this.year = year;
    this.players = players;
    this.role = "";
}

game.prototype.setRole = function(role) {
    this.role = role;
}

game.prototype.toJSON = function() {
    const obj = {name: this.name, genre: this.genre, year: this.year, players: this.players, role: this.role};
    const json = JSON.stringify(obj);
    return json;
}

var movies = new game("Uncharted", "Action", "2022", "n/a");
logItType(movies);
logItType(movies.toJSON());

movies.setRole("Movie");
logItType(movies); 
logItType(movies.toJSON());
evalmachine.<anonymous>:20
logItType(movies);
^

ReferenceError: logItType is not defined
    at evalmachine.<anonymous>:20:1
    at ContextifyScript.Script.runInThisContext (vm.js:25:33)
    at Object.runInThisContext (vm.js:97:38)
    at run ([eval]:1020:15)
    at onRunRequest ([eval]:864:18)
    at onMessage ([eval]:828:13)
    at emitTwo (events.js:106:13)
    at process.emit (events.js:191:7)
    at process.nextTick (internal/child_process.js:758:12)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
var games = [
    new game("Minecraft", "Sandbox", "2011", "141 Million"),
    new game("R6S", "FPS", "2015", "70 Million"),
    new game("Fortnite", "3rd Person BR", "2017", "270 Million"),
    new game("Apex", "1st Person BR", "2019", "~100 Million"),
    new game("Roblox", "Sandbox", "2006", "230 Million"),
    new game("Pokemon Go", "Augmented Reality", "2016", "632 Million"),
    new game("Halo Infinite", "FPS", "2021", "20 Million"),
    new game("Terraria", "Sandbox", "2011", "~66 Million"),
]

function Theatre(movies, games){
    movies.setRole("Movie");
    this.movies = movies;
    this.theatre = [movies];
    this.games = games;
    this.games.forEach(game => { game.setRole("Game"); this.theatre.push(game); });
    this.json = [];
    this.theatre.forEach(game => this.json.push(game.toJSON()));
}

compsci = new Theatre(movies, games);

logItType(compsci.theatre);
logItType(compsci.theatre[0].name);
logItType(compsci.json[0]);
logItType(JSON.parse(compsci.json[0]));
Classroom.prototype._toHtml = function() {
    var style = (
      "display:inline-block;" +
      "border: 2px solid grey;"
    );
  
    var body = "";
    body += "<tr>";
    body += "<th><mark>" + "Name" + "</mark></th>";
    body += "<th><mark>" + "Genre" + "</mark></th>";
    body += "<th><mark>" + "Year" + "</mark></th>";
    body += "<th><mark>" + "Players" + "</mark></th>";
    body += "</tr>";
  for (var row of compsci.classroom) {
    body += "<tr>";
    body += "<td>" + row.name + "</td>";
    body += "<td>" + row.genre + "</td>";
    body += "<td>" + row.year + "</td>";
    body += "<td>" + row.players + "</td>";
    body += "<tr>";
  }

  return (
    "<div style='" + style + "'>" +
      "<table>" +
        body +
      "</table>" +
    "</div>"
  );

};

$$.html(compsci._toHtml());