MV Is there a way to check and count states on a target, without using a million if conditions?

So, I've made this simple little function:

Code:
//Check conditions.
//Returns a value. The higher the number, the more positive status effects are n it. Lower means more negative effects.
Titan_CheckConditions = function(b) {
    var n = 0;

    //Positive states
    if(b.isStateAffected(42))
        n = n + 1;

    if(b.isStateAffected(43))
        n = n + 2;

    if(b.isStateAffected(44))
        n = n + 1;

    if(b.isStateAffected(45))
        n = n + 2;

    //Negative stats
    if(b.isStateAffected(52))
        n = n - 1;

    if(b.isStateAffected(53))
        n = n - 2;

    if(b.isStateAffected(54))
        n = n - 1;

    if(b.isStateAffected(55))
        n = n - 2;

    //Positive conditions
    if(b.isStateAffected(62))
        n = n + 1;

    if(b.isStateAffected(63))
        n = n + 1;

    if(b.isStateAffected(72))
        n = n + 1;

    if(b.isStateAffected(73))
        n = n + 2;

    //Negative conditions
    if(b.isStateAffected(82))
        n = n - 1;

    if(b.isStateAffected(83))
        n = n - 1;

    if(b.isStateAffected(91))
        n = n - 1;

    if(b.isStateAffected(94))
        n = n - 3;

    if(b.isStateAffected(95))
        n = n - 2;

    return n;
}


Basically, bad states lower the returned number, and good states raise the number. This is useful for, say, enemy AIs, as they can now check to see if they should dispel targets. You don't wanna dispel a poisoned ally if it has a million positive states on it after all!

The only thing is, this code feels super bad. It works, but I feel there's gotta be a better way to do this than a mountain of if conditions! Like, there's gotta be simple loops or something, right?

I think this is the right board for this question.
@TheTitan99
Code:
var positiveStates = []; //put positive states ids
var negativeStates = []; //put negative states ids
for (var i = 0; i <= positiveStates - 1; i++){
    n += 1;
}

for (var i = 0; i <= positiveStates - 1; i++){
    n -= 1;
}

But then, if you want a different values for different states, then

Code:
var positiveStates = []; //put positive states ids
var negativeStates = []; //put negative states ids
for (var i = 0; i <= positiveStates - 1; i++){
    if (b.isStateAffected(positiveStates[i]){
        n += Number($dataStates[positiveStates[i]].meta["buff"]);
    }
}

for (var i = 0; i <= negativeStates - 1; i++){
    if (b.isStateAffected(negativeStates[i]){
        n -= Number($dataStates[positiveStates[i]].meta["debuff"]);
    }
}

and place in your states notetags: https://prnt.sc/xo8lnx

Actually you can stick to the only one notetag, but using two will give you further informations about boosts.
Because of my age I leave that way a hint for myself in case I forgot what function/state etc do
Thank you! There were a few typos in that code, but after fixing those, it works like a charm! Much, much cleaner code.

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-way-to-check-and-count-states-on-a-target-without-using-a-million-if-conditions.132682/