Week 7 Lesson 1 example

by Lucille Kenney

JavaScript

var k = "Harvard";
function myFunc(k){
    console.log("this is the function parameter k: "+k);
    k = "Yale";
    console.log("this is still the function parameter k: "+k);
}
myFunc(k);
console.log("When we're done, the global k is: "+k);
console.log("This is the same as: "+window.k);

function AddrBookEntry(f, l, a, e) {
    this.fname = f;
    console.log("this is the function parameter f: "+f);
    this.lname = l;
    this.addr = a;
    this.email = e;
 
    this.personRole = "student";
    this.getFullName = function(){
                return this.fname + " " + this.lname;
    }
}