Can someone provide a clear explanation of my question using an example? I have an array of objects structured like this:
[{a:"a",b:"",c:"c"}, {a:"a",b:"b",c:""}, {a:"",b:"b",c:"c"}, {d:""} ]
and [a,b]
.
Initially, I need to verify that the objects in the first array contain the properties from the second array, and then check if those properties are empty strings or undefined. If they are, I want to set them to "something". The final result should appear as follows:
[{a:"a",b:"something",c:"c"}, {a:"a",b:"b",c:""}, {a:"something", b:"b",c:"c"}, {a:"something", b:"something", d:""} ]
Please note that while I currently have a functional code, it is not very aesthetically pleasing and I am looking for a more elegant approach.