var msg = "Hello, World!";
console.log(msg)
Hello, World!
function logIt(output) {
    console.log(output);
}
logIt(msg);
Hello, World!
function logItType(output) {
    console.log(typeof output, ";", output);
}
console.log("Looking at dynamic nature of types in JavaScript")
logItType("hello"); // String
logItType(2020);    // Number
logItType([1, 2, 3]);
Looking at dynamic nature of types in JavaScript
string ; hello
number ; 2020
object ; [ 1, 2, 3 ]
function Event(name, day, time) {
    this.name = name;
    this.day = day;
    this.time = time;
    this.role = "";
}

// define a setter for role in Event data
Event.prototype.setRole = function(role) {
    this.role = role;
}

// define a JSON conversion "method" associated with Event
Event.prototype.toJSON = function() {
    const obj = {name: this.name, day: this.day, time: this.time, role: this.role};
    const json = JSON.stringify(obj);  // json/string is useful when passing data on internet
    return json;
}

// make a new Event and assign to variable geology
var geology = new Event("Dynamic Planet", "Friday", "5-6PM");  // object type is easy to work with in JavaScript
logItType(geology);  // before role
logItType(geology.toJSON());  // ok to do this even though role is not yet defined

// output of Object and JSON/string associated with Teacher
geology.setRole("Teacher");   // set the role
logItType(geology); 
logItType(geology.toJSON());
object ; Event { name: 'Dynamic Planet', day: 'Friday', time: '5-6PM', role: '' }
string ; {"name":"Dynamic Planet","day":"Friday","time":"5-6PM","role":""}
object ; Event {
  name: 'Dynamic Planet',
  day: 'Friday',
  time: '5-6PM',
  role: 'Teacher' }
string ; {"name":"Dynamic Planet","day":"Friday","time":"5-6PM","role":"Teacher"}
var events = [ 
    new Event("Rocks and Minerals", "Tuesday", "5-6PM"),
    new Event("Astronomy", "Tuesday", "6:30-8PM"),
    new Event("Forestry", "Saturday", "10-11AM"),
    new Event("Green Generation", "Sunday", "2-3PM"),
];

// define a classroom and build Classroom objects and json
function Classroom(geology, events){ // 1 geology, many student
    // start Classroom with Teacher
    geology.setRole("Best");
    this.geology = geology;
    this.classroom = [geology];
    // add each Student to Classroom
    this.events = events;
    this.events.forEach(student => { student.setRole("mid"); this.classroom.push(student); });
    // build json/string format of Classroom
    this.json = [];
    this.classroom.forEach(Event => this.json.push(Event.toJSON()));
}

// make a CompSci classroom from formerly defined geology and events
compsci = new Classroom(geology, events);

// output of Objects and JSON in CompSci classroom
logItType(compsci.classroom);  // constructed classroom object
logItType(compsci.classroom[0].name);  // abstract 1st objects name
logItType(compsci.json[0]);  // show json conversion of 1st object to string
logItType(JSON.parse(compsci.json[0]));  // show JSON.parse inverse of JSON.stringify
object ; [ Event {
    name: 'Dynamic Planet',
    day: 'Friday',
    time: '5-6PM',
    role: 'Best' },
  Event {
    name: 'Rocks and Minerals',
    day: 'Tuesday',
    time: '5-6PM',
    role: 'mid' },
  Event {
    name: 'Astronomy',
    day: 'Tuesday',
    time: '6:30-8PM',
    role: 'mid' },
  Event {
    name: 'Forestry',
    day: 'Saturday',
    time: '10-11AM',
    role: 'mid' },
  Event {
    name: 'Green Generation',
    day: 'Sunday',
    time: '2-3PM',
    role: 'mid' } ]
string ; Dynamic Planet
string ; {"name":"Dynamic Planet","day":"Friday","time":"5-6PM","role":"Best"}
object ; { name: 'Dynamic Planet',
  day: 'Friday',
  time: '5-6PM',
  role: 'Best' }
// define an HTML conversion "method" associated with Classroom
Classroom.prototype._toHtml = function() {
    // HTML Style is build using inline structure
    var style = (
      "display:inline-block;" +
      "border: 2px solid grey;" +
      "box-shadow: 0.8em 0.4em 0.4em grey;"
    );
  
    // HTML Body of Table is build as a series of concatenations (+=)
    var body = "";
    // Heading for Array Columns
    body += "<tr>";
    body += "<th><mark>" + "Name" + "</mark></th>";
    body += "<th><mark>" + "Day" + "</mark></th>";
    body += "<th><mark>" + "Time" + "</mark></th>";
    body += "<th><mark>" + "Role" + "</mark></th>";
    body += "</tr>";
    // Data of Array, iterate through each row of compsci.classroom 
    for (var row in compsci.classroom) {
      // tr for each row, a new line
      body += "<tr>";
      // td for each column of data
      body += "<td>" + compsci.classroom[row].name + "</td>";
      body += "<td>" + compsci.classroom[row].day + "</td>";
      body += "<td>" + compsci.classroom[row].time + "</td>";
      body += "<td>" + compsci.classroom[row].role + "</td>";
      // tr to end line
      body += "<tr>";
    }
  
     // Build and HTML fragment of div, table, table body
    return (
      "<div style='" + style + "'>" +
        "<table>" +
          body +
        "</table>" +
      "</div>"
    );
  
  };
  
  // IJavaScript HTML processor receive parameter of defined HTML fragment
  $$.html(compsci._toHtml());
</table></div> </div> </div> </div> </div> </div>
const resultContainer = console.getElementById("result");
for (const row of data) {
    // tr for each row
    const tr = console.createElement("tr");
    // td for each column
    const name = console.createElement("td");
    const day = console.createElement("td");
    const time = console.createElement("td");
    const role = console.createElement("td");
    // data is specific to the API
    name.innerHTML = row.name;
    day.innerHTML = row.day; 
    time.innerHTML = row.time; 
    role.innerHTML = row.role; 
    // this build td's into tr
    tr.appendChild(name);
    tr.appendChild(day);
    tr.appendChild(time);
    tr.appendChild(role);
    // add HTML to container
    resultContainer.appendChild(tr);
}
evalmachine.<anonymous>:1
const resultContainer = document.getElementById("result");
                                 ^

ReferenceError: document is not defined
    at evalmachine.<anonymous>:1:34
    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)
let score = 0
let total = 0
let count = 0
let correct = 0
class Jeopardy {
    constructor(question, answer, point) {
        this.question = question;
        this.answer = answer;
        this.point = point;
    }
    CheckAnswer(guess) {
        return guess === this.answer
    }
}
let q1 = new Jeopardy('What is the capital of Chile?', 'Santiago', 2);
let q2 = new Jeopardy('What is the capital of France?', 'Paris', 1);
let q3 = new Jeopardy('What is the capital of Czech Republic?', 'Prague', 2);
let q4 = new Jeopardy('What is the capital of Portugal?', 'Lisbon', 2);
let q5 = new Jeopardy('What is the capital of Ethiopia?', 'Addis Ababa', 2);
let q6 = new Jeopardy('Who is the President of the United States?', 'Joe Biden', 1);
let q7 = new Jeopardy('Who is the leader of Russia?', 'Vladimir Putin', 1);
let q8 = new Jeopardy('What is the capital of the United States?', 'Washington DC', 1);
let q9 = new Jeopardy('What country is being invaded by Russia?', 'Ukraine', 2);


const qarray = [q1, q2, q3, q4, q5, q6, q7, q8, q9]

function QNA(number) {
    for (let i = 0; i < number; i++) {
        const randomValue = qarray[Math.floor(Math.random() * qarray.length)];
        var index = qarray.indexOf(randomValue);
        if (index > -1) {
            qarray.splice(index, 1);
        }
        let guess = prompt(randomValue.question + " Points: " + randomValue.point);
        count = count + 1
        total = total + randomValue.point
        if (randomValue.CheckAnswer(guess)) {
            score = score + randomValue.point;
            correct = correct + 1
            console.getElementById('answer').innerHTML = "Well Done!";
            console.getElementById('score').innerHTML = "Your score is " + score + "/" + total;
            console.getElementById('correct').innerHTML = "You got " + correct + " questions correct out of " + count;
        }
        else {
            console.getElementById('answer').innerHTML = "Nice Try!";
            console.getElementById('score').innerHTML = "Your score is " + score + "/" + total;
            console.getElementById('correct').innerHTML = "Sorry, you have gotten " + correct + " questions correct out of " + count;
        }
        }
}
function Tester() {

}
</div>
Name Day Time Role
Dynamic Planet Friday 5-6PM Best
Rocks and Minerals Tuesday 5-6PM mid
Astronomy Tuesday 6:30-8PM mid
Forestry Saturday 10-11AM mid
Green Generation Sunday 2-3PM mid