I have below object. I want to iterate over it and need to fetch only key's values of ability and value key.
var object = [{
ability: "Strong",
name: "STRENGTH",
value: "customer has 10 properties",
type: "MultiChoice"
},
{
ability: "Good",
name: "STRENGTH",
value: "customer has 5 properties",
type: "MultiChoice"
},
{
ability: "average",
name: "STRENGTH",
value: "customer has 3 properties",
type: "MultiChoice"
}
]
So my expected output should be like below.
[{
ability: "Strong"
value: "customer has 10 properties"
},
{
ability: "Good"
value: "customer has 5 properties"
},
{
ability: "average"
value: "customer has 3 properties"
}
]
Then I again want to use above object to iterate over it and bind its values to dropdown. So my drop-down will display "value" to end user and DB will have "ability". I am trying below code snippet but its not giving expected output. Something I am doing wrong here.
var object = [{
ability: "Strong",
name: "STRENGTH",
value: "customer has 10 properties",
type: "MultiChoice"
},
{
ability: "Good",
name: "STRENGTH",
value: "customer has 5 properties",
type: "MultiChoice"
},
{
ability: "average",
name: "STRENGTH",
value: "customer has 3 properties",
type: "MultiChoice"
}
]
let multiChoiceResult = [];
let ability, value
Object.entries(object).map(([key, value]) => {
ability = value.ability;
value = value.value;
multiChoiceResult.push(ability, value);
});
console.log(multiChoiceResult);
rangesetDeduced, rangesetValue)