If player has item and has x of item do Y

How would I do this? I know with an event I can say, do you have X in your inventory, but whats the script call to then say:

do you have X item and X of item? if so do Y, else do Z
Code:
var item = $dataItems[n];
if($gameParty.hasItem(item) && $gameParty.numItems(item) >= x) {
do something...
}
else {
do something else...
}

You can check more about these methods in the rpg_objects.js libs, in the Game_Party's class.

EDIT:
But I think you can proceed simply this way:
Code:
var item = $dataItems[n];
if($gameParty.numItems(item) >= x) {
do something...
}
else {
do something else...
}

Checking the number of the items, I think It will checks automatically the existence of that item in the party's inventory, too.
thanks for this.
You're welcome, man 😂

Original thread: https://forums.rpgmakerweb.com/threads/if-player-has-item-and-has-x-of-item-do-y.80472/