Having read about JS objects I believe I can adds methods in the following way:
var activity = {
name: null,
start: null,
finish: null,
alarm: function (x) {
if (x === this.start) {
return true;
}
if (x !== this.start) {
return false;
}
}
colour: function (x) {
if (x < this.start) {
return "red";
}
if (x > this.start && x < this.finish) {
return "green";
}
if (x > this.finish) {
return "grey";
}
}
};
When I run this through JSFiddle it says
Expected '(end)' instead saw ':'.
Next to the line with "colour" in it.
I'm not sure what I have done wrong?