Some checks failed
test / Test completion check (push) Has been cancelled
test / test (20, macos-latest) (push) Has been cancelled
test / test (20, ubuntu-latest) (push) Has been cancelled
test / test (20, windows-latest) (push) Has been cancelled
test / test (22, macos-latest) (push) Has been cancelled
test / test (22, ubuntu-latest) (push) Has been cancelled
test / test (22, windows-latest) (push) Has been cancelled
test / test (24, macos-latest) (push) Has been cancelled
test / test (24, ubuntu-latest) (push) Has been cancelled
test / test (24, windows-latest) (push) Has been cancelled
21 lines
320 B
JavaScript
21 lines
320 B
JavaScript
class Order {
|
|
constructor(id, items) {
|
|
this.id = id;
|
|
this.items = items;
|
|
}
|
|
|
|
total() {
|
|
return this.items.reduce((acc, v) => {
|
|
acc += v.quantity * v.value;
|
|
return acc;
|
|
}, 0);
|
|
}
|
|
|
|
toString() {
|
|
return `Order ${this.id}, Total: ${this.total()}`;
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
Order,
|
|
};
|