如果在某一点后有太多 9 做某事

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

所以基本上数学 js 有一个问题,它必须执行这个等式 1:999,否则它会崩溃。

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

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

现在,如果你用它计算 1:999,它会给出一个错误,但我想要它来查看方程式是否还有更多的 9。例如,如果我做了 1:9999999,它也会给出一个错误,但基本上这个等式中超过三个 9 的任何东西都会给出一个错误。

您可以使用 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");
}

以下示例显示 regular expression 用于测试字符串是否为“1:999”、“1:9999”、“1:99999”、...

if (/^1:999+$/.test(arg)) {