function type(output){
    console.log(output);
}

function Chess(name, rank, yrsplay){
    this.name = name;
    this.rank = rank;
    this.yrsplay = yrsplay;
    this.exp = ""
}

Chess.prototype.setExp = function(exp){
    this.exp = exp;
}

Chess.prototype.toJSON = function(){
    const obj = {name: this.name, rank: this.rank, yrsplay: this.yrsplay, exp: this.exp};
    const json = JSON.stringify(obj);
    return json;
}

var chess_players = [ 
  new Chess("Magnus Carlsen",2856, 26),
  new Chess("Ding Liren",2811,13),
  new Chess("Ian Nepomniachtchi",2793,28),
];

function Leaderboard(chess_play){ 

  chess_play.setExp("Grandmaster");
  this.chess_play = chess_play;
  this.Leaderboard = [chess_play];

  
  this.json = [];
  this.classroom.forEach(Chess => this.json.push(Chess.toJSON()));
}

leaders = new Leaderboard(chess_players)

Chess.prototype._toHtml = function() {
    var style = (
      "display:inline-block;" +
      "border: 2px solid grey;" +
      "box-shadow: 0.8em 0.4em 0.4em grey;"
    );
  
    var body = "";
    body += "<tr>";
    body += "<th><mark>" + "Name" + "</mark></th>";
    body += "<th><mark>" + "Rank" + "</mark></th>";
    body += "<th><mark>" + "Years Played" + "</mark></th>";
    body += "<th><mark>" + "Experience" + "</mark></th>";
    body += "</tr>";
    for (var row of leaders.classroom) {
      body += "<tr>";
      body += "<td>" + row.name + "</td>";
      body += "<td>" + row.rank + "</td>";
      body += "<td>" + row.yrsplay + "</td>";
      body += "<td>" + row.exp + "</td>";
      body += "<tr>";
    }
  
    return (
      "<div style='" + style + "'>" +
        "<table>" +
          body +
        "</table>" +
      "</div>"
    );
  
  };
  
  $$.html(leaders._toHtml());
evalmachine.<anonymous>:30
  chess_play.setExp("Grandmaster");
             ^

TypeError: chess_play.setExp is not a function
    at new Leaderboard (evalmachine.<anonymous>:30:14)
    at evalmachine.<anonymous>:39:11
    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)