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

How can I get every LI element's innerHTML and display as string? How can I get every LI element's innerHTML and display as string?

Refresh page after clicking button (ok / cancel) Refresh page after clicking button (ok / cancel)

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