Answer

Answer

JavaScript test

Решением является возврат самого объекта в каждом методе(return this;).

let ladder = {
  step: 0,
  up() {
    this.step++;
    return this; // <--
  },
  down() {
    this.step--;
    return this; // <--
  },
  showStep() {
    alert( this.step );
    return this; // <--
  }
}

ladder.up().up().down().up().down().showStep(); // 1

Report Page