Just map them per index (if they have the same length) in a simple loop. Here is a demo:
a = ["Isolated-1", "SVT_FedPortGroup", "SVT_StoragePortGroup", "VM Network", "test-pg-2002"]
b = ["target_Isolated-1", "target_SVT_FedPortGroup", "target_SVT_StoragePortGroup", "target_VM Network", "target_test-pg-2002"]
c = {
"NetworkMaps": []
}
for (var i = 0; i < a.length; i++) {
c.NetworkMaps.push({
"ENVID": null,
"SourcePG": a[i],
"TargetPG": b[i]
})
}
console.log(c);
4
solved How to convert two Array [closed]