-
Notifications
You must be signed in to change notification settings - Fork 16
Almog Lavi #3
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?
Almog Lavi #3
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.
Good work, i left you some comments
store.ts
Outdated
| ) /* : add return types */ { | ||
| return []; | ||
| function getAvailableProducts(store : Store) : Product[] { | ||
| return store.products.filter((product)=>product.inStock===true); |
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 also do return store.products.filter((product)=>product.inStock);
Because inStock is a variable and the variable is boolean
store.ts
Outdated
| if (product.tags.includes(tag)) | ||
| prodWithTag.push(product); | ||
| }); | ||
| return prodWithTag; |
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.
Looks like a filter function?
function getProductsByTag(store: Store, tag: string): Product[] {
return store.products.filter(p => p.tags.includes(tag));
}
store.ts
Outdated
| return []; | ||
| function getAvailableProductsByTag(store : Store, tag : string) : Product[] { | ||
| const prodByTag : Product[] = getProductsByTag(store, tag); | ||
| return prodByTag.filter((product) => product.inStock===true); |
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.
product.inStock could be the condition in here as well
No description provided.