1

So basically there is an issue with math js where id it has to do this equation 1:999 or anymore nines it will crash.

        try
        {
            if(args == "1:999") return message.channel.send('That question is not allowed');

        } catch(error){
            message.channel.send("there was an error")
        }

Right now if you have it calculate 1:999 it gives an error, but I want it instead to see if the equation has any more nines. ex if i did 1:9999999 it would also give an error but basically anything over with more than three nines in this equation will give an error.

2 Answers2

1

The following example shows a regular expression being used to test if a string is of the form "1:999", "1:9999", "1:99999", ...

if (/^1:999+$/.test(arg)) {
MikeM
  • 13,156
  • 2
  • 34
  • 47
  • 1
    Thanks you for the help, I'm kind of new to JavaScript and never knew this existed. I would upvote, but I don't have enough "reputation" – Tuba Player Sep 18 '21 at 19:10
0

You can use the String#EndsWith to check if the string ends with the number of 9 you want using String#repeat

if (args.endsWith('9'.repeat(count))) {
  console.log("Too many nines");
}
a.mola
  • 3,883
  • 7
  • 23