17 lines
295 B
JavaScript
17 lines
295 B
JavaScript
let ladder = {
|
|
step: 0,
|
|
up() {
|
|
this.step++;
|
|
return this;
|
|
},
|
|
down() {
|
|
this.step--;
|
|
return this;
|
|
},
|
|
showStep: function() { // shows the current step
|
|
alert( this.step );
|
|
return this;
|
|
}
|
|
};
|
|
ladder.up().up().down().showStep().down().showStep(); // shows 1 then 0
|