I have this object array:
var materials=[{sample:"A21"},{sample:"A22"},{sample:"A23"}];
The target is to create an new array replacing "sample" name with its corresponding value...
Result: var materials2=[{A21:"A21"},{A22:"A22"},{A23:"A23"}];
is this possible?
i've tried below loop passing key as string but without any luck!
for(i=0; i<materials.length; i++){
materials2.push({"'"+materials[i].sample+"'":materials[i].sample})
}
Any help will be appreciated! Thanks!