The following functions loops through a list. If a particular item within a sublist has a blank value, then it replaces it with "None."
lst.forEach(function (d) {
if(d.thefirstcolumn){} else {d.thefirstcolumn = "None"};
if(d.somethingelse){} else {d.somethingelse = "None"};
if(d.random){} else {d.random = "None"};
if(d.cold){} else {d.cold = "None"};
if(d.cole){} else {d.cole = "None"};
if(d.colf){} else {d.colf = "None"};
if(d.colg){} else {d.colg = "None"};
if(d.colh){} else {d.colh = "None"};
});
This is not very scalable, because I have to reference every item within every sublist, so I'd to create a function that does this for all items so that I don't have to reference.
For example, it would be something short like the following where it would accomplish the same result as the previous code and do it for every item within every sublist of the list.
lst.forEach(function (d) {
if(d.col){} else {d.col = "None"};
});
Above, I mean d.col to refer to d.cola, d.colb, d.colc, d.cold, and all other items. How would I make this work?
Bonus question is that how would I apply the following function as well only if the the item within the sublist is a number otherwise just apply the previous function?
For example,it would try this on each item of the sublist
d.col = parseInt(d.col, 10);
Otherwise it would run the following if the item was not a number
if(d.colh){} else {d.colh = "None"}