Skip to content
This repository has been archived by the owner on Oct 26, 2020. It is now read-only.

Zision week 9.2 #1038

Open
wants to merge 2 commits into
base: manchester3
Choose a base branch
from

Conversation

zision71
Copy link

Only attempt Exercises for this week, Didn't try Last exercise. Please review.


cartContains() {
// Use console.log() to output everything contained in your cart
console.log(`Your shopping cart has ${this.total} items : ${this.array} `);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the output easier to read you can do this instead:

${this.array.join(', ')}


addItem(item) {
this.array.push(item);
this.total++;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but the code would be better if you only had one instance variable this.array and instead got the total from a function i.e.

total() {
  return this.array.length;
}

This is better because you don't have to keep track of two variables, you only need one.

@evanrolfe
Copy link

Nice work 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants