Skip to content

Conversation

@lumiscript
Copy link

Do not merge.. PR created for Code Review purposes

@@ -0,0 +1,17 @@
import React from "react";
import ItemList from "../Item-list/Item-list";
const cart = props => {
Copy link
Author

Choose a reason for hiding this comment

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

to support standards, name your components with a starting capital letter so we are able to differentiate between functions and components.

Copy link
Author

Choose a reason for hiding this comment

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

refactor this to use map instead of for.. break the operation into 2 steps.. the first step should multiply each item price by its quantity and the second step will add up all the items in the array. this can be 2 separate functions chained together.

What i described above is functional programming 101

};

addToCart = (id) => {
const inventoryIndex = this.state.inventory.findIndex(p => {
Copy link
Author

Choose a reason for hiding this comment

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

you can refactor this operation to be a filter and you return the output of the filter

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.

3 participants