Skill 1.B:Determine code that would be used to complete code segments (ie For, While, Recursion)

Shown in each code segment below..

Skill 4.C: Determine if two or more code segments yield equivalent results (be sure to Discuss how you know results are the same)

The results are the same because the outputs are the same. We have just used different techniques.

Skill 5.A: Describe the behavior of a given segment of program code (describe the difference in recursion versus for & while loops, perhaps add timing to determine speed)

The time it takes for recursion is longer than while.

console.log("Hello, World!");
Hello, World!
var msg = "Hello, World!";
console.log(msg);
Hello, World!
function logIt(output) {
    console.log(output);
}
logIt(msg);
Hello, World!
console.log("Reuse!")
logIt("Hello, Students!");
logIt(2022)
Reuse!
Hello, Students!
2022

Scrum Master Data

// 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 = "Scrum Master";
}

// 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);  // json/string is useful when passing data on internet
    return json;
}

// make a new Person and assign to variable teacher
var scrummaster = new Person("Vidhi Kulkarni", "@VidhiKulkarni", 2024);  // object type is easy to work with in JavaScript
logItType(scrummaster);  // before role
logItType(scrummaster.toJSON());  // ok to do this even though role is not yet defined

// output of Object and JSON/string associated with Teacher
scrummaster.setRole("Scrum Master");   // set the role
logItType(scrummaster); 
logItType(scrummaster.toJSON());
object ; Person {
  name: 'Vidhi Kulkarni',
  ghID: '@VidhiKulkarni',
  classOf: 2024,
  role: 'Scrum Master'
}
string ; {"name":"Vidhi Kulkarni","ghID":"@VidhiKulkarni","classOf":2024,"role":"Scrum Master"}
object ; Person {
  name: 'Vidhi Kulkarni',
  ghID: '@VidhiKulkarni',
  classOf: 2024,
  role: 'Scrum Master'
}
string ; {"name":"Vidhi Kulkarni","ghID":"@VidhiKulkarni","classOf":2024,"role":"Scrum Master"}
// define a student Array of Person(s)
var team = [ 
    new Person("William Wu", "@willcyber", 2024),
    new Person("Riya Patil", "@riya-patil", 2024),
    new Person("Lily Wu", "@lwu1822", 2024),
];

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

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

// 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: 'Vidhi Kulkarni',
    ghID: '@VidhiKulkarni',
    classOf: 2024,
    role: 'Scrum Master'
  },
  Person {
    name: 'William',
    ghID: '@willcyber',
    classOf: 2024,
    role: 'Team Member'
  },
  Person {
    name: 'Riya',
    ghID: '@riya-patil',
    classOf: 2024,
    role: 'Team Member'
  },
  Person {
    name: 'Lily',
    ghID: '@lwu1822',
    classOf: 2024,
    role: 'Team Member'
  }
]
string ; Vidhi Kulkarni
string ; {"name":"Vidhi Kulkarni","ghID":"@VidhiKulkarni","classOf":2024,"role":"Scrum Master"}
object ; {
  name: 'Vidhi Kulkarni',
  ghID: '@VidhiKulkarni',
  classOf: 2024,
  role: 'Scrum Master'
}

Team Page Screen

// 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>" + "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 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].ghID + "</td>";
      body += "<td>" + compsci.classroom[row].classOf + "</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> </div>
Name GitHub ID Class Of Role
Vidhi Kulkarni @VidhiKulkarni 2024 Scrum Master
William @willcyber 2024 Team Member
Riya @riya-patil 2024 Team Member
Lily @lwu1822 2024 Team Member