A copy of the JavaScript functions in the head element:
// sample-9-2-method-functions.js

// method to set the grade property
function SetGrade( newGrade )
  {
  this.grade = newGrade;
  }

// constructor for Student objects, with setGrade method
function Student (firstName, lastName, id)
  {
  this.first = firstName;
  this.last  = lastName;
  this.id    = id;
  this.grade = "";
  this.setGrade = SetGrade;
  }
      
A copy of the JavaScript in the body element:
// sample-9-2-methodr.js
// constructor sample

var fred = new Student("Fred", "Schmidt", 123456);
var mary = new Student("Mary", "Jones", 654321);

fred.setGrade("A");
document.write("First name: ", fred.first, ", Grade: ", fred.grade);
document.write("<br />");

mary.grade = "A";
document.write("First name: ", mary.first, ", Grade: ", mary.grade);
document.write("<br />");