I have an object like this
data: [
{
"Type":"100, S4",
"Model":"1 serie, e82",
"Manufacturer":"BMW",
"Vehicle":"Cars"
},
{
"Type":"type 2",
"Model":"a serie",
"Manufacturer":"Toyota",
"Vehicle":"Cars"
},
{
"Type":"type 3",
"Model":"v4",
"Manufacturer":"Toyota",
"Vehicle":"SUVs"
}
]
then I used jquery and lodash library with expect to return distinct value from the object.
Tried #1:
$.each( data, function( i, value ) {
var vehicles = _.uniqBy(value);
console.log(vehicles);
});
Result: got 3 empty arrays printed in console.log
Tried #2:
$.each( data, function( i, value ) {
var vehicles = _.uniqBy(value.Vehicle);
console.log(vehicles);
});
Result: 4 arrays within split characters
(4) ["C", "a", "r", "s"]
(4) ["C", "a", "r", "s"]
(4) ["S", "U", "V", "s"]
I expected to got an array within
["Cars", "SUVs"]
How could I deal with it? Thanks for help!