Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Sumator {
- constructor() {
- this.data = [];
- this.add(item) {
- this.data.push(item);
- }
- this.sumNums() {
- let sum = 0;
- for (let item of this.data)
- if (typeof (item) === 'number')
- sum += item;
- return sum;
- }
- this.removeByFilter(filterFunc) {
- this.data = this.data.filter(x => !filterFunc(x));
- }
- this.toString() {
- if (this.data.length > 0)
- return this.data.join(", ");
- else
- return '(empty)';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement