Skip to content

Data and functions 1#9

Open
Tsurmi wants to merge 4 commits intoAmericaCampaign:masterfrom
Tsurmi:data-and-functions-1
Open

Data and functions 1#9
Tsurmi wants to merge 4 commits intoAmericaCampaign:masterfrom
Tsurmi:data-and-functions-1

Conversation

@Tsurmi
Copy link

@Tsurmi Tsurmi commented Aug 23, 2017

No description provided.

Copy link
Contributor

Choose a reason for hiding this comment

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

Change the users parameter in your find to user or u, since it's just a single user object:

return data.users.find(u => u.id === id)

Copy link
Contributor

Choose a reason for hiding this comment

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

Change the name of the find function parameter to reflect the fact that it's just a single product. See my comments below.

Copy link
Contributor

Choose a reason for hiding this comment

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

You only need to pass in the data.

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of calling your variable activeUser, call it currentUser. We haven't determined if it's actually an active user yet.

@jcheroske
Copy link
Contributor

Comments in your code! Please seek help if needed!

Copy link
Contributor

@jcheroske jcheroske left a comment

Choose a reason for hiding this comment

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

You're ready to move on. Please keep pushing up your changes as you work.

const getProductById = (data, id) => {
if (data == null || data.products == null || id == null) {
return null
}else{
Copy link
Contributor

Choose a reason for hiding this comment

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

drop this else

const getUserById = (data, id) => {
if (data == null || id == null || data.users == null) {
return null
}else{
Copy link
Contributor

Choose a reason for hiding this comment

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

You can drop this else too.

const getActiveUsers = (data) => {
if (data == null || data.users == null) {
return null
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

This else can go too.

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

Comments