Creating an Attack Skill That Deals More Damage if the Enemy Has a Defensive Buff

So I've currently been working on a project in MZ, and have moved onto a character that relies heavily on physical damage. I had an idea for a skill that, like the title says, checks to see if the enemy has a defensive buff, and if they do then the attack deals more damage, also removing the defensive buffs in the process.

I already have a good handle on things like the damage formula and setting it up in a common event, but it's checking for the buff that's getting me. I'm still learning Javascript honestly, I've been able to create a skill that increases in damage based on if you have low hp or not. But I'm not sure how to check for def buffs.

The idea would be to create an if branch: If enemy has phys def buff or mag def buff, do big damage and remove the buffs. If not, do slightly weaker than normal damage.

What line of Javascript code would I need for this skill?

(Also apologies if this was posted on the wrong board, it's been awhile since I posted here.)
In damage formula b.buff(X) gives the buff level (positive when buffed, negative when debuffed).

For X defence is 3 and magic defence is 5

EDIT:
Oh and since you wanted to also get rid of the (de)buffs, it's:
b.clearBuffs();
b.refresh();

EDIT 2:
Those scripts clear all the buffs, if you only want to clear all def and mdf buffs, someone else has to help LOL
EDIT:
Oh and since you wanted to also get rid of the (de)buffs, it's:
b.clearBuffs();
b.refresh();
eraseBuff(x) can be used, but since the buff dispel is to happen after the damage calc, using the editor's built in remove (de)buff effect on the skill would work fine
eraseBuff(x) can be used, but since the buff dispel is to happen after the damage calc, using the editor's built in remove (de)buff effect on the skill would work fine
In damage formula b.buff(X) gives the buff level (positive when buffed, negative when debuffed).

For X defence is 3 and magic defence is 5

EDIT:
Oh and since you wanted to also get rid of the (de)buffs, it's:
b.clearBuffs();
b.refresh();

EDIT 2:
Those scripts clear all the buffs, if you only want to clear all def and mdf buffs, someone else has to help LOL
omg so it's literally just "If: b.buff(3 5)" and nothing else?

man a part of me thought it was more complex

thanks, really appreciate this!!
No check it with OR? if ((b.buff(3) > 0) || (b.buff(5) > 0))

edit: added some brackets
No check it with OR? if ((b.buff(3) > 0) || (b.buff(5) > 0))

edit: added some brackets
Yeah, found that out a bit after I replied here. Ended up doin some experimenting and got the if statement to work with:

$target.isBuffAffected(3) || $target.isBuffAffected(5)

Appreciate the help though! It's been awhile since I've used RPG Maker so I'm a bit rusty lmao

Original thread: https://forums.rpgmakerweb.com/threads/creating-an-attack-skill-that-deals-more-damage-if-the-enemy-has-a-defensive-buff.174764/