我们需要编写一个 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 = ... 阅读更多