I have this array of objects and I want to add the value of the object below in the same order as it is inside the items array, Any suggestion?
const items = [{
tshirt: "Model TS",
jeans: "ModelXW",
},
{
sneakers: "indcdsc54",
furniture: "Table31S"
},
{
dress: "indc54",
short: "shortS2"
},
];
either an object or an array, which one should be easier?
const obj = [
"localhost:8080.com",
"localhost:3000.com",
"localhost:7000.com",
]
Expected output:
const items = [{
tshirt: "Model TS",
jeans: "ModelXW",
website: "localhost:8080.com",
},
{
sneakers: "indcdsc54",
furniture: "Table31S",
website: "localhost:3000.com",
},
{
dress: "indc54",
short: "shortS2",
website: "localhost:7000.com",
},
];
I have tried this way with no success, any suggestion?
const items = [{
tshirt: "Model TS",
jeans: "ModelXW"
},
{
sneakers: "indcdsc54",
furniture: "Table31S"
},
{
dress: "indc54",
short: "shortS2"
}
];
const obj = [
"localhost:8080.com",
"localhost:3000.com",
"localhost:7000.com",
]
let newArray = obj.map(uri => items.map(i => i["website"] = uri ))
console.log(newArray)
objshould be an array as it currently throws a syntax error. Plus objects do not have a.mapmethod