I try to find the highest key value of 'sequence' where it's value is 'true'. I know it's not sql, but I would like know if it's possible to do this request on javascript.
For example, in my case I would like to have : 5 because "70" it's the highest value with bug_tab is true.
Here my js array myTab :
[
{
"value": "AHAH",
"field": "15",
"color": "",
"bug_tab": true,
"sequence": "40",
"text": "slash"
},
{
"value": "BABA",
"field": "8",
"color": "",
"bug_tab": true,
"sequence": "50",
"text": "zip"
},
{
"value": "CACA",
"field": "25",
"color": "",
"bug_tab": false,
"sequence": "63",
"text": "vite"
},
{
"value": "DADA",
"field": "22",
"color": "",
"bug_tab": true,
"sequence": "66",
"text": "meat"
},
{
"value": "EVA",
"field": "13",
"color": "",
"bug_tab": true,
"sequence": "70",
"text": "zut"
},
{
"value": "FAFA",
"field": "jut",
"color": "",
"bug_tab": false,
"sequence": "90",
"text": "cut"
}
]
What I have do :
This return the first occurence where bug_tab is equal to true :
var indexbugTabArray = myTab.map(function(o) { return o.bug_tab; }).indexOf(true);
Advance thanks,