On the problem of array traversal

there is such an array
[
{key:59,value:ture},
{key:59,value:flase},
{key:58,value:true},
{key:57,value:true},
{key:56,value:true},
{key:58,value:false}
]

what I want to get is that if the key value is repeated:
, compare the value after the repeated key. If the number of true is one more than false, then the value of the key is raised and a string connected by underscore is generated. If the key value is not duplicated, it is directly proposed to generate 57key 56.
if there are as many value values as false, the generated string does not contain the key
, for example, The output of the above array is 57056,
kneel to ask the god to answer!

Aug.31,2021

var a = [
            {key:59,value:true},
            {key:59,value:false},
            {key:58,value:true},
            {key:57,value:true},
            {key:56,value:true},
            {key:58,value:false}
        ];
//join('_')
a.reduce((pre, cur, index, arr) => {
    var keyIndex = pre.indexOf(cur.key);
    if (keyIndex < 0) {
        pre.push(cur.key);
    } else { 
        (arr.filter(item => item.key === cur.key && item.value).length - 
        arr.filter(item => item.key === cur.key && !item.value).length) <= 0 
        && pre.splice(keyIndex, 1); //truefalse
    }
    return pre;
},[]).join('_')

var a = [
            {key:59,value:true},
            {key:59,value:false},
            {key:58,value:true},
            {key:57,value:true},
            {key:56,value:true},
            {key:58,value:false}
        ];
var obj = {};
a.forEach((temp,index)=>{
    if(obj[temp.key]){
        obj[temp.key] +='_'+index;
    }else{
        obj[temp.key] = ''+index;
    }
});
for(var key in obj){
    if(obj[key].indexOf('_')>-1){
        var b = obj[key].split('_');
        var count = 0;
        b.forEach(temp=>{
            if(a[temp].value) countPP;
            else count--;
        });
        if(count>0) obj[key] = true;
        else obj[key] = false;
    }else{
        obj[key] = true;
    }
}
var s = a.filter(temp=>obj[temp.key]).map(temp=>temp.key).join('_');
document.write(s);

you try

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38153-4ed4d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38153-4ed4d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?