Created
August 16, 2016 23:06
-
-
Save Bijesse/e7cab67c780f702054442504c45d555d to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=e7cab67c780f702054442504c45d555d
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Protoyping activity</title> | |
</head> | |
<body> | |
<!-- Put your page markup here --> | |
</body> | |
</html> |
This file contains hidden or 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
// Fix the code so that the expected output (below) prints | |
// Remember to use the errors in the console (to the right) if you are having trouble | |
// the human constructor giving us an object | |
function Human (name) { | |
this.name = name; | |
} | |
//prototype is accesible from any other human instance | |
Human.prototype.speak = function () { | |
console.log('Hello, my name is ' + this.name); | |
}; | |
function SuperHuman (name) { | |
Human.call(this, name); | |
} | |
SuperHuman.prototype = new Human(); | |
SuperHuman.prototype.fly = function () { | |
console.log("It's a bird; it's a plane; it's " + this.name); | |
}; | |
var superman = new SuperHuman('batman'); | |
superman.speak(); | |
superman.fly(); | |
// expected output: | |
// Hello, my name is superman | |
// It's a bird; it's a plane; it's superman |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment