map values in an array to values in another array in Javascript map values in an array to values in another array in Javascript

please I have 2 arrays in the following format

const images = ["image1", "image2", "image3", "image4"]

const items = [{quantity: 1}, {quantity: 2}, {quantity: 4}, {quantity: 1}]

I need the final output to be like below

const newArray = [
    {
        image: "image1",
        quantity: 1
    },
    {
        image: "image2",
        quantity: 2
    },
    {
        image: "image3",
        quantity: 4
    },
    {
        image: "image4",
        quantity: 1
    },
]


from Stackoverflow

Comments

Popular posts from this blog

\\u0000 cannot be converted to text error \\u0000 cannot be converted to text error

I am having trouble with this ajax timer it is not doing what I expect and does not execute I am having trouble with this ajax timer it is not doing what I expect and does not execute

How to create @click on select menu in VueJS How to create @click on select menu in VueJS