I have the array object data stored in a variable called hi[0].child.
hi[0].child = [
{code: "food", name: "burger"},
{code: "cloth", name: "outer"},
{code: "fruit", name: "apple"},
]
My goal is to create a new variable named hello, change the key values of hi[0].child, and store it in the hello variable.
Specifically, I want to change the key value of code to value and name to label. The expected values are as follows:
expected answer
hello = [
{label: "burger", value: "food"},
{label: "outer", value: "cloth"},
{label: "apple", value: "fruit"},
]
However, I encounter errors when using my code.
I receive the message 'Did not expect a type annotation here.'
How can I correct my code? Here is my code snippet:
let hello = []
hi[0].child.map((v) => {
hello.push(label: v.name, value: v.code)
})