let allInfo = ['John', 'Doe'];
allInfo.map((name) => console.log("arr", name.firstName))
The statement above creates an array. I am looking to loop through the values and insert them into a new array for display in a dropdown menu.
const info = [
{ value: "firstName", label: "firstName" },
{ value: "first",label: "first"},
{ value: "lastName", label: "lastName" }
]
I aim to iterate over the values of allInfo
and assign them to the values in info
. Instead of hardcoding value = "firstName"
, I want to fetch it from the allInfo
array. Could someone assist me with this task?