I am working a demo react project, and got stuck to pick name and value of js object and push to an array. which I want to use for queryparams. The js objects looks as follow
const ingredient = [
{ salad: 0, bacon: 0 },
{ cheese: 0, meat: 0 }
]
here I want the key and the value to push to an array. ex.
const arrays = []
I try this way and did not got it correct.
=> for (let name of ingredient){
arrays.push(name + ingredient[name])
}
=> arrays
(2) ["[object Object]undefined", "[object Object]undefined"]
how do I push only the name and value correctly so I will able to use them in the url?
thanks in advance for your help.