I have an array of javascript objects that I am working with. The keys are dynamically generated and there will be an unknown number of them.
I am trying to loop over the object and replace a piece of data in its value.
Here is an example below:
var obj = [{
name: 'Joe',
age: 21,
randomCol1: 'Blah<br>Blah<br>Blah',
randomCol2: 'Blah<br>Blah<br>Blah',
randomCol3: 'Blah<br>Blah<br>Blah'
},
{
name: 'Bob',
age: 25,
randomCol1: 'Blah<br>Blah<br>Blah',
randomCol2: 'Blah<br>Blah<br>Blah',
randomCol3: 'Blah<br>Blah<br>Blah'
}]
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
obj[key].replace(/<br>/g,'\r\n')
}
}
In the object, I am trying to replace the <br> with \r\n. The column names are not always known.
Should I be doing this through a loop or some type of mapping? Just needing to convert this data before passing it to an excel export where I need to utilize line breaks.
array []then loop thekeys..