knyte, is this better?
var person = function(name) {
"use strict";
this.name = name;
this.location = 'home';
this.money = 0;
this.wantToGoToEvent = {
BerlinOpen: true
};
this.canAffordToGoToEvent = function(event) {
return this.money > event.cost;
};
this.visit = function(place) {
this.location = place;
return this;
};
};
var you = new person("Bane");//Bane is broke
var fizzer = new person("Fizzer");
fizzer.money = 100000;//Fizzer has a job
var events = {
BerlinOpen: {
location: 'Berlin',
cost: 200//for argument's sake
}
};
if (you.wantToGoToEvent.BerlinOpen && you.canAffordToGoToEvent(events.BerlinOpen) && fizzer.wantToGoToEvent.BerlinOpen && fizzer.canAffordToGoToEvent(events.BerlinOpen)) {
//if you and fizzer can go to the event, go to the event
you.visit(events.BerlinOpen.location);
fizzer.visit(events.BerlinOpen.location);
//you see Fizzer
}
Edit: added BerlinOpen event cost.
Edited 12/13/2017 00:21:38