const item = {date:'2021-07-22',
bfast: { 'name': 'spaghetti' ,'uid': 'pZjKW2rbOPOMYmdBoOzt' , 'done': false },
lunch: { 'name': 'spaghetti' ,'uid': 'pZjKW2rbOPOMYmdBoOzt', 'done': false },
dinner: { 'name': 'spaghetti', 'uid': 'pZjKW2rbOPOMYmdBoOzt', 'done': false }
}
const formatRecipe = (uid ,time, item, uid, name) => {
const = date.time
if (time === 'bfast') {
item.breakfast = {'name' : name, 'uid': uid, 'done': false}
} else if (time === 'lunch') {
item.lunch = {'name' : name, 'uid': uid, 'done': false}
} else {
item.dinner = {'name' : name, 'uid': uid, 'done': false}
}
return { day : [item] }
}
document.write(formatRecipe(item.date,'bfast', item, 'abc', 'spaghetti')['2021-07-22'])
hi everyone im stuck at some data structure issue. as you can see i need to format the data as such so that it can be rendered by some library function. but as i have highlighted the “day” inside, the return statement wont refer to the parameter of the function, whereas i need the day as the key of the returned object. does anyone know a way to solve this?