You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
508 B
JavaScript
29 lines
508 B
JavaScript
/*
|
|
* Once upon a time...
|
|
*/
|
|
|
|
class Vampire {
|
|
constructor(props) {
|
|
this.location = props.location;
|
|
this.birthDate = props.birthDate;
|
|
this.deathDate = props.deathDate;
|
|
this.weaknesses = props.weaknesses;
|
|
}
|
|
|
|
get age() {
|
|
return this.calcAge();
|
|
}
|
|
|
|
calcAge() {
|
|
return this.deathDate - this.birthDate;
|
|
}
|
|
}
|
|
|
|
// ...there was a guy named Vlad
|
|
|
|
const Dracula = new Vampire({
|
|
location: 'Transylvania',
|
|
birthDate: 1428,
|
|
deathDate: 1476,
|
|
weaknesses: ['Sunlight', 'Garlic']
|
|
}); |