Number check failing/getting ignored. Discord.js

I’m trying to make a strike system that allows up to 3 strikes, so, when I try to check if the strikeNumber is between 1 and 3, it ignores the if statement, I’m not sure why, but I’ve tried multiple ways to fix it, and it still seems to fail.

Here is the if statement that is getting ignored:

           let strikeNumber = args[2] //(Args 0 is the command it self, Args 1 is the user, Args 2 is the `Strikenumber`, and Args 3 is the reason.)

            if (!strikeNumber) {
                return message.reply("Please state the number of the strike. (Example: 1, 2, 3)")
            } if (!strikeNumber > 0 && !strikeNumber < 4) {
                return message.reply("Strike number must be from 1 to 3.")

Not all the code is here, and there is no error, it just ignores the if statement.

>Solution :

Try replacing the second condition with this, it checks if the number is below zero or above 4

if ( num < 0 || num > 4 )

Leave a Reply