added showStep method to our chain in the task

This commit is contained in:
Tofpu 2021-11-16 09:37:00 +02:00 committed by GitHub
parent a829155758
commit 83d20033e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,12 +28,14 @@ ladder.up();
ladder.up();
ladder.down();
ladder.showStep(); // 1
ladder.down();
ladder.showStep(); // 0
```
Modify the code of `up`, `down` and `showStep` to make the calls chainable, like this:
```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.