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
Post a Comment