javascriptdiscord.jsmathjs

If there is too many 9s after a certain point do something


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.


Solution

  • 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)) {