Damage Formula Help

I want to make a skill that does a flat amount of damage for each negative state the target is effected by. So for example, it would deal 2 points of damage if the target is effected by state 4, and 6 points of damage if it's effected by state 4, state 5, and state 6. I know how to make damage formulas conditional on a state, but not additive based on multiple states. Any ideas?
Looks like it would be:

(b.isStateAffected(4) ? 2 : 0) + (b.isStateAffected(5) ? 2 : 0) + (b.isStateAffected(6) ? 2 : 0)

I haven't tested this.
Works perfectly. Thank you very much!

Original thread: https://forums.rpgmakerweb.com/threads/damage-formula-help.105004/