ga-wdi-boston / js-objects-prototypes

Other
0 stars 161 forks source link

Code snippet for superHero prototype code along #7

Open payne-chris-r opened 8 years ago

payne-chris-r commented 8 years ago
'use strict';
​
// create a new superhero
const Hero = function (name, alias, power) {
  this.name = name;
  this.alias = alias;
  this._power = power;
};
​
// assigning the new hero's attributes
let superMan = new Hero('Clark Kent', 'Superman', 'faster than a speeding bullet');
​
let spiderMan = new Hero('Peter Parker', 'Spiderman', 'acts like a spider');
​
// create a usePower method on the hero prototype (will use the superhero's power that is called)
Hero.prototype.usePower = function () {
  return this._power;
};
​
// create a revealID method on the hero prototype (will reveal the superhero's real name that is called)
Hero.prototype.revealID = function () {
  return this.alias + 's real identity is ' + this.name + '!';
};
gaand commented 8 years ago

Storm, Catwoman? Work with me here. ;-).

jrhorn424 commented 8 years ago

Added to solution as of 9fa59a32381a4a4e5ac97bc92fec6a046ba31fef. Ok to close @payne-chris-r? I believe I asked you to open this, but I can't recall.