我们需要编写一个 JavaScript 函数,该函数接收两个字符串作为输入,并返回第一个字符串在第二个字符串中出现的次数。假设我们的字符串如下所示:const main = 'This is the is main is string';我们必须在上面的“main”字符串中查找下面字符串的出现次数:const sub = 'is';让我们为此函数编写代码 - 示例const main = 'This is the is main is string'; const sub = 'is'; const countAppearances = (main, sub) => { const regex = new RegExp(sub, "g"); let count = ... 阅读更多