-
-
Save codecademydev/a3cfa90aa425dcbdc805e70f9e21886f to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 = ageDifference(alice, billy); | |
console.log(diff); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment