Skip to content

Commit cbdb218

Browse files
authored
Merge pull request #2777 from Tofpu/missing-showstep-patch
Included missing showStep methods
2 parents 7e575de + 690c223 commit cbdb218

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

1-js/04-object-basics/04-object-methods/8-chain-calls/solution.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let ladder = {
2323
}
2424
};
2525

26-
ladder.up().up().down().up().down().showStep(); // 1
26+
ladder.up().up().down().showStep().down().showStep(); // shows 1 then 0
2727
```
2828

2929
We also can write a single call per line. For long chains it's more readable:
@@ -33,7 +33,7 @@ ladder
3333
.up()
3434
.up()
3535
.down()
36-
.up()
36+
.showStep() // 1
3737
.down()
38-
.showStep(); // 1
38+
.showStep(); // 0
3939
```

1-js/04-object-basics/04-object-methods/8-chain-calls/task.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ ladder.up();
2828
ladder.up();
2929
ladder.down();
3030
ladder.showStep(); // 1
31+
ladder.down();
32+
ladder.showStep(); // 0
3133
```
3234

3335
Modify the code of `up`, `down` and `showStep` to make the calls chainable, like this:
3436

3537
```js
36-
ladder.up().up().down().showStep(); // 1
38+
ladder.up().up().down().showStep().down().showStep(); // shows 1 then 0
3739
```
3840

3941
Such approach is widely used across JavaScript libraries.

0 commit comments

Comments
 (0)