Skip to content

Instantly share code, notes, and snippets.

@NikitaGlukhi
Created December 10, 2018 12:57
Show Gist options
  • Save NikitaGlukhi/098788d2fb5fc99f7324757969097d81 to your computer and use it in GitHub Desktop.
Save NikitaGlukhi/098788d2fb5fc99f7324757969097d81 to your computer and use it in GitHub Desktop.
Task 3 for constructor function
const Accumulator = function (startingValue) {
this.value = startingValue;
this.read = function () {
this.value += +prompt('Insert new value (task 3)', 0);
}
};
const accumulator = new Accumulator(1);
accumulator.read();
accumulator.read();
alert(`Текукщее значение: ${accumulator.value}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment