var msg = "Hello, World!";
console.log(msg);
Hello, World!
function logIt(output) {
    console.log(output);
}
logIt(msg);
Hello, World!
function Person(name, ghID, classOf, period) {
    this.name = name;
    this.ghID = ghID;
    this.classOf = classOf;
    this.period = period;
    this.role = "";
}

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

Person.prototype.toJSON = function() {
    const obj = {name: this.name, ghID: this.ghID, classOf: this.classOf, period: this.period, role: this.role};
    const json = JSON.stringify(obj);
    return json;
}

var teacher = new Person("Mr M", "jm1021", 1977, 3);  
logItType(teacher);  
logItType(teacher.toJSON());  

teacher.setRole("Teacher");   
logItType(teacher); 
logItType(teacher.toJSON());
object ; Person {
  name: 'Mr M',
  ghID: 'jm1021',
  classOf: 1977,
  period: 3,
  role: '' }
string ; {"name":"Mr M","ghID":"jm1021","classOf":1977,"period":3,"role":""}
object ; Person {
  name: 'Mr M',
  ghID: 'jm1021',
  classOf: 1977,
  period: 3,
  role: 'Teacher' }
string ; {"name":"Mr M","ghID":"jm1021","classOf":1977,"period":3,"role":"Teacher"}
var students = [ 
    new Person("Sarah Liu", "sarah-liu", 2024, 3),
    new Person("Amay Advani", "amayadvani", 2024, 3),
    new Person("Emma Shen", "e-shen2022", 2024, 3),
    new Person("Vivian Ni", "vivianknee", 2024, 3),
];

function Classroom(teacher, students){ 
    teacher.setRole("Teacher");
    this.teacher = teacher;
    this.classroom = [teacher];
    this.students = students;
    this.students.forEach(student => { student.setRole("Student"); this.classroom.push(student); });
    this.json = [];
    this.classroom.forEach(person => this.json.push(person.toJSON()));
}

compsci = new Classroom(teacher, students);

logItType(compsci.classroom);  
logItType(compsci.classroom[0].name);  
logItType(compsci.json[0]);  
logItType(JSON.parse(compsci.json[0]));
object ; [ Person {
    name: 'Mr M',
    ghID: 'jm1021',
    classOf: 1977,
    period: 3,
    role: 'Teacher' },
  Person {
    name: 'Sarah Liu',
    ghID: 'sarah-liu',
    classOf: 2024,
    period: 3,
    role: 'Student' },
  Person {
    name: 'Amay Advani',
    ghID: 'amayadvani',
    classOf: 2024,
    period: 3,
    role: 'Student' },
  Person {
    name: 'Emma Shen',
    ghID: 'e-shen2022',
    classOf: 2024,
    period: 3,
    role: 'Student' },
  Person {
    name: 'Vivian Ni',
    ghID: 'vivianknee',
    classOf: 2024,
    period: 3,
    role: 'Student' } ]
string ; Mr M
string ; {"name":"Mr M","ghID":"jm1021","classOf":1977,"period":3,"role":"Teacher"}
object ; { name: 'Mr M',
  ghID: 'jm1021',
  classOf: 1977,
  period: 3,
  role: 'Teacher' }
Classroom.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>" + "GitHub ID" + "</mark></th>";
    body += "<th><mark>" + "Class Of" + "</mark></th>";
    body += "<th><mark>" + "Period" + "</mark></th>";
    body += "<th><mark>" + "Role" + "</mark></th>";
    body += "</tr>";
    for (var row of compsci.classroom) {
      body += "<tr>";
      body += "<td>" + row.name + "</td>";
      body += "<td>" + row.ghID + "</td>";
      body += "<td>" + row.classOf + "</td>";
      body += "<td>" + row.period + "</td>";
      body += "<td>" + row.role + "</td>";
      body += "<tr>";
    }
  
    return (
      "<div style='" + style + "'>" +
        "<table>" +
          body +
        "</table>" +
      "</div>"
    );
  
  };
  
  $$.html(compsci._toHtml());
</table></div> </div> </div> </div> </div> </div> </div>
Name GitHub ID Class Of Period Role
Mr M jm1021 1977 3 Teacher
Sarah Liu sarah-liu 2024 3 Student
Amay Advani amayadvani 2024 3 Student
Emma Shen e-shen2022 2024 3 Student
Vivian Ni vivianknee 2024 3 Student