Skip to content

Conversation

@Elad-Abutbul
Copy link

No description provided.

Copy link
Member

@Tamir198 Tamir198 left a 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
Copy link
Member

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);
Copy link
Member

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
Copy link
Member

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(
Copy link
Member

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 = {
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants