Looking to replace any empty spaces in a string with the value "N/A." For example, given an array:
var array= ["value1", undefined, "value3"];
var array2= ["value1", "value2", "value3"];
var array3= ["value1", "value2", undefined];
This is a dynamically generated array so the values can vary. I have 3 instances of arrays with different populated values. My goal is to remove all instances of 'undefined' and replace them with "N/A."
array.toString().replace(/\:''/gi, ": \"N/A\"");
outputs: "value1,,value3"; however, I want it to be: "value1, N/A, value3"
I am struggling with using regex to achieve this. Any suggestions on how to accomplish this?