Skip to content

Instantly share code, notes, and snippets.

@meech-ward
Created May 18, 2018 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meech-ward/465fad00a9f3718bc6f97e3457102b61 to your computer and use it in GitHub Desktop.
Save meech-ward/465fad00a9f3718bc6f97e3457102b61 to your computer and use it in GitHub Desktop.
class Banana {
constructor () {
this.ripeness = 0;
}
age() {
this.ripeness++;
}
report() {
if (this.ripeness === 7) {
console.log("hmn, delicious");
} else if (this.ripeness > 7) {
console.log("brown, unfit for consumption, suitable for muffins");
} else if (this.ripeness < 7) {
console.log("ew, crunchy");
} else {
console.log("this cannot happen");
}
}
}
let b1 = new Banana();
setInterval(b1.age, 1000);
setInterval(b1.report, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment