i have a arrray of objects where i wish to convert the data from medicine to type string. The only problem is instead of returning the array of objects is returing me the array of medicine.
Example input:
data = [{medicine: 1234, info: "blabla"},{medicine: 9585, info: "blabla"},..]
desired output:
data = [{medicine: "1234", info: "blabla"},{medicine: "9585", info: "blabla"},..]
What im getting? Array of medicine numbers.
Here is my code:
var dataMedicines = _.map(data, 'medicine').map(function(x) {
return typeof x == 'number' ? String(x) : x;
});
_.map(data, 'medicine')strips out and return the medicine number into the next mapping function.