var msg = "Test practice variables and a message!";
console.log(msg);
Test practice variables and a message!

Dynamic or Loosely typed language (string, number)

JavaScript is a loosely typed language, meaning you don't have to specify what type of information will be stored in a variable in advance. The variable type is determined at runtime. This is similar to Python and most interpretive languages. Java which is a compiled language is strongly typed, thus you will see string, integer, double, and object in the source code. In JavaScript, the "typeof" keyword returns the type.

function logItType(output) {
    console.log(typeof output, ";", output);
}
console.log("WEEEEEEEEEEEEEEEEEEE")
logItType("Hello Mr. Yeung!"); // String
logItType(2022);    // Number
logItType([1, 2, 3]);  // Object is generic for this Array, which similar to Python List
WEEEEEEEEEEEEEEEEEEE
string ; Hello Mr. Yeung!
number ; 2022
object ; [ 1, 2, 3 ]

Building a Person Function/Class object and JSON

Input you, mr yeung as the person with teacher role, idk your github name, and your class of date! Also set yorur role to 'Best Teacher :D' cause you're just better (give me an A pls)!!!

// define a function to hold data for a Person
function Person(name, ghID, classOf) {
    this.name = name;
    this.ghID = ghID;
    this.classOf = classOf;
    this.role = "";
}

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

// define a JSON conversion "method" associated with Person
Person.prototype.toJSON = function() {
    const obj = {name: this.name, ghID: this.ghID, classOf: this.classOf, role: this.role};
    const json = JSON.stringify(obj);
    return json;
}

// make a new Person and assign to variable teacher
var teacher = new Person("Mr Yeung", "Syeung2", 2013);
teacher.setRole("Coolest Teacher :)");

// output of Object and JSON/string associated with Teacher
logItType(teacher);  // object type is easy to work with in JavaScript
logItType(teacher.toJSON());  // json/string is useful when passing data on internet
object ; Person {
  name: 'Mr Yeung',
  ghID: 'Syeung2',
  classOf: 2013,
  role: 'Coolest Teacher' }
string ; {"name":"Mr Yeung","ghID":"Syeung2","classOf":2013,"role":"Coolest Teacher"}

Making the Classroom

// define a student Array of Person(s)
var students = [ 
    new Person("Naja", "NajaAFonseca", 2025),
    new Person("Lydia", "lydia-c2", 2024),
    new Person("Lina", "linaawad1", 2024),
    new Person("Dylan", "DylanGarrett", 2025),
];

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

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

// 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 ; [ Person {
    name: 'Mr Yeung',
    ghID: 'Syeung2',
    classOf: 2013,
    role: 'Teacher' },
  Person {
    name: 'Naja',
    ghID: 'NajaAFonseca',
    classOf: 2025,
    role: 'Student' },
  Person {
    name: 'Lydia',
    ghID: 'lydia-c2',
    classOf: 2024,
    role: 'Student' },
  Person {
    name: 'Lina',
    ghID: 'linaawad1',
    classOf: 2024,
    role: 'Student' },
  Person {
    name: 'Dylan',
    ghID: 'DylanGarrett',
    classOf: 2025,
    role: 'Student' } ]
string ; Mr Yeung
string ; {"name":"Mr Yeung","ghID":"Syeung2","classOf":2013,"role":"Teacher"}
object ; { name: 'Mr Yeung',
  ghID: 'Syeung2',
  classOf: 2013,
  role: 'Teacher' }

Making a Table :D

// define an HTML conversion "method" associated with Classroom
Classroom.prototype._toHtml = function() {
    // HTML Style is build using inline structure
    var style = (
      "display:inline-block;" +
      "background:black;" +
      "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>" + "GitHub ID" + "</mark></th>";
    body += "<th><mark>" + "Class Of" + "</mark></th>";
    body += "<th><mark>" + "Role" + "</mark></th>";
    body += "</tr>";
    // Data of Array, iterate through each row of compsci.classroom 
    for (var row of compsci.classroom) {
      // tr for each row, a new line
      body += "<tr>";
      // td for each column of data
      body += "<td>" + row.name + "</td>";
      body += "<td>" + row.ghID + "</td>";
      body += "<td>" + row.classOf + "</td>";
      body += "<td>" + 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>

Big Idea 1 'Program and Purpose'

  1. Do we have final project ideas for a PBL Web Project?

Yes, we have a final project idea for a PBL Web Project!

  1. Are we considering a project that is best for our educational purpose?

Yes! We are going to learn so much during this educational purpose!

  1. Is the project going to hold team members interest for 8 weeks?

Yes, it is going to be a very fun and very interesting project!

  1. Does the project have potential for someone to use it beyond the 8 weeks? ie Customer or Sponsor needed?

Yes, game usage is inevitable, and snake is a classic so it will be fun forever

  1. Does the project have potential to be used for Create Performance Task submission?

Yes!

</div>
Name GitHub ID Class Of Role
Mr Yeung Syeung2 2013 Teacher
Naja NajaAFonseca 2025 Student
Lydia lydia-c2 2024 Student
Lina linaawad1 2024 Student
Dylan DylanGarrett 2025 Student