const isFieldEmpty = (data) => {
const newObj = Object.keys(data).map((key) => {
if (data[key] === '') {
const tempKey = key;
key.value = 'N/A';
return tempKey;
}
return key;
});
return newObj;
};
It should search for all empty strings in the object then replace with N/A. Above is my attempt, but it's not working correctly.
Expected input:
const input = { a: "foo", b: "bar", c: "", d: "baz", e: ""}
Expected output:
const foobar = { a: "foo", b: "bar", c: "N/A", d: "baz", e: "N/A"}