For example I have this arrays:
a = [1, 2, 3];
b = ["a", "b", "c"];
I want to make one object from these arrays that would look like this:
c = [{
a: 1,
b: "a"
},
{
a: 2,
b: "b"
},
{
a: 3,
b: "c"
}];
You can use Array.map
let a = [1, 2, 3];
let b = ["a", "b", "c"];
let c = a.map((v,i) => ({a:v, b: b[i]}));
console.log(c);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With