Conversation
jcheroske
left a comment
There was a problem hiding this comment.
You wandered off into the weeds on getOrderInfo. Look at my comments and perhaps start over and just take it step by step.
| if (DATA == null || DATA.products == null) { | ||
| return null | ||
| } | ||
| let mostExpProd // = undefined |
There was a problem hiding this comment.
if you really want to make it explicit, you could just do:
let mostExpProd = undefined
but putting in the comment is also good form.
| @@ -0,0 +1,28 @@ | |||
| import DATA from '../DATA' | |||
There was a problem hiding this comment.
Don't import DATA! It's being passed to you.
| @@ -0,0 +1,21 @@ | |||
| import DATA from '../DATA' | |||
There was a problem hiding this comment.
Don't import DATA! You can remove this import from all of your answer files.
| import getProductById from './getProductById' | ||
| import getUserById from './getUserById' | ||
|
|
||
| const getOrderInfo = (DATA, orderId) => { |
There was a problem hiding this comment.
The function only takes one parameter: DATA. Drop the orderId param.
| import getUserById from './getUserById' | ||
|
|
||
| const getOrderInfo = (DATA, orderId) => { | ||
| if (DATA == null || DATA.users == null || orderId == null) { |
There was a problem hiding this comment.
Your second test should be testing for the existence of data.orders
| for (let i = 0; i < DATA.orders.length; i++) { | ||
| const orderInfo = { | ||
| orderId: orderId, | ||
| userName: userName, |
There was a problem hiding this comment.
Set the userName the way you are setting it on line 19. Same with price, but use currentOrder instead of DATA.order.
| let orderId = DATA.orders.id | ||
| let userName = getUserById(DATA.orders.userId).name | ||
| let price = getProductById(DATA.order.productId).price | ||
| } |
| } | ||
| let orderInfoArr = [] | ||
|
|
||
| for (let i = 0; i < DATA.orders.length; i++) { |
There was a problem hiding this comment.
Make the first line of your for loop:
const currentOrder = DATA.orders[i]
Then go from there...
|
|
||
| for (let i = 0; i < DATA.orders.length; i++) { | ||
| const orderInfo = { | ||
| orderId: orderId, |
There was a problem hiding this comment.
Set orderId from the currentOrder's id property.
Having trouble getting this function to work. I have a bunch of stuff in the wrong places, but I'm not sure what proper placement would look like.
const orderInfo = { orderId: orderId, userName: userName, price: price }&let orderId = DATA.orders.id let userName = getUserById(DATA.orders.userId).name let price = getProductById(DATA.order.productId).price