Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created April 4, 2016 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/373068f73fca6e2a7a0f4f52edf219f7 to your computer and use it in GitHub Desktop.
Save codecademydev/373068f73fca6e2a7a0f4f52edf219f7 to your computer and use it in GitHub Desktop.
Codecademy export
// Our person constructor
function Person (name, age) {
this.name = name;
this.age = age;
}
// We can make a function which takes persons as arguments
// This one computes the difference in ages between two people
var ageDifference = function(person1, person2) {
return person1.age - person2.age;
}
var alice = new Person("Alice", 30);
var billy = new Person("Billy", 25);
// get the difference in age between alice and billy using our function
var diff = console.log("The age between Alice and Billy is " + ageDifference(alice,billy));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment