-
Notifications
You must be signed in to change notification settings - Fork 16
or_chen #9
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?
or_chen #9
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.
Hey looks good overall, one thing i noticed is that you are using explicitly return inside arrow functions.
Meaning:
const somethig = () => {
return "value"
}For simple function you can really make then 1 liner:
const somethig = () => "value"I added a comment about this.
This is just opinion, you are not wrong
| ) /* : add return types */ { | ||
| return []; | ||
| function getAvailableProducts(store: Store): Product[] { | ||
| return store.products.filter((product) => { return product.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.
For such short function you could also use return store.products.filter((product) => product.stock
| cart :number[], | ||
| ) :number { | ||
| let total = 0 | ||
| store.products.forEach((product) => { |
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.
Read about reduce function it can help in here
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 used forEach because this was the requirement
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.
And you did a great job, just telling you that js provides not only forEach
test