added showStep method to our chain in the task
This commit is contained in:
parent
a829155758
commit
83d20033e4
1 changed files with 3 additions and 1 deletions
|
@ -28,12 +28,14 @@ ladder.up();
|
||||||
ladder.up();
|
ladder.up();
|
||||||
ladder.down();
|
ladder.down();
|
||||||
ladder.showStep(); // 1
|
ladder.showStep(); // 1
|
||||||
|
ladder.down();
|
||||||
|
ladder.showStep(); // 0
|
||||||
```
|
```
|
||||||
|
|
||||||
Modify the code of `up`, `down` and `showStep` to make the calls chainable, like this:
|
Modify the code of `up`, `down` and `showStep` to make the calls chainable, like this:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
ladder.up().up().down().showStep(); // 1
|
ladder.up().up().down().showStep().down().showStep(); // shows 1 then 0
|
||||||
```
|
```
|
||||||
|
|
||||||
Such approach is widely used across JavaScript libraries.
|
Such approach is widely used across JavaScript libraries.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue