Is there a way to select a specific value in JSON based on another property value? For example, I would like to pass the configuration_code
and retrieve the corresponding description
.
configurations: Array(2)
0:
configuration_code: "SPWG"
description: "Cuscade Cus Date"
1:
configuration_code: "KKS"
description: "Krop Kret Sowel"
...
This is the code I have tried:
configDelete: function(index, config) {
console.log(this.quote.configurations.find(x => x.configuration_code[config] == index).description);
}
When passing SPWG
, it should log Cuscade Cus Date
. Likewise, passing KKS
should log Krop Kret Sowel
.
However, my current code is not functioning as expected. How can I troubleshoot and fix this issue?