Skip to content

Instantly share code, notes, and snippets.

@Bijesse
Created August 16, 2016 23:06
Show Gist options
  • Save Bijesse/e7cab67c780f702054442504c45d555d to your computer and use it in GitHub Desktop.
Save Bijesse/e7cab67c780f702054442504c45d555d to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=e7cab67c780f702054442504c45d555d
<!DOCTYPE html>
<html>
<head>
<title>Protoyping activity</title>
</head>
<body>
<!-- Put your page markup here -->
</body>
</html>
// 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