100
rated 0 times
[
107]
[
7]
/ answers: 1 / hits: 52334
/ 8 Years ago, thu, june 16, 2016, 12:00:00
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;
});
More From » lodash