-
Notifications
You must be signed in to change notification settings - Fork 16
elad-abutbul #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
elad-abutbul #8
Conversation
Tamir198
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked only the ts file because the logic is the same as in the js file
Looks good overall
store.js
Outdated
| @@ -0,0 +1,77 @@ | |||
| // store.ts | |||
| // Homework - Online Store System | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the future remove those comments
store.ts
Outdated
| ) /* : add return types */ { | ||
| return []; | ||
| function getAvailableProducts(store: Store): Product[] { | ||
| return store.products.filter((p: Product): boolean => p.inStock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The :boolean is fine but ts can infer its type so you don't really need it in here, just an opinion
store.ts
Outdated
| return []; | ||
| function getProductsByTag(store: Store, tag: string): Product[] { | ||
| return store.products.filter( | ||
| (p: Product): boolean => p.tags.indexOf(tag) !== -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also create another condition:
here is a psudo of the condition:
product => product.tags.includes(tag)
But both are fine
| function getCartTotalInStock(store: Store, cart: number[]): number { | ||
| return getCartProducts(store, cart) | ||
| .filter((p: Product): boolean => p.inStock) | ||
| .reduce( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work using the reduce
store.js
Outdated
| // ------------------------------------ | ||
| // Store data (5 products) | ||
| // ------------------------------------ | ||
| var store = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can change this file into a .ts file and give the store interface and create one
No description provided.