This is my code:
function makeCounter(x) {
x = x || 0;
var obj = {
value: x,
increment: function(){
x = x + 1;
return x;
},
decrement: function() {
x = x - 1;
return x;
}
}
return obj;
}
var counter = makeCounter();
console.log(counter.increment()); // output is 1
console.log(counter.value); // output is 0
Now, I want to know how to edit the code so that the value will be 1 after counter.increment().