April 2018
Beginner to intermediate
426 pages
10h 19m
English
The count property also works as the size of the stack. So, for the size method, we can simply return the count property:
size() { return this.count;}
And to verify whether the stack is empty, we can compare if the count value is 0 as follows:
isEmpty() { return this.count === 0;}