首页 > 解决方案 > React Native 代码中的嵌套返回给出了语法错误(“:”预期)

问题描述

这是我在此来源上找到的流图的代码:https ://observablehq.com/@jamila/streamgraph-transitions 我正在尝试将其合并到我的反应本机应用程序中

const bumps = {
  // Inspired by Lee Byron’s test data generator.
   bump(a, n) {
    const x = 1 / (0.1 + Math.random());
    const y = 2 * Math.random() - 0.5;
    const z = 10 / (0.1 + Math.random());
    for (let i = 0; i < n; ++i) {
      const w = (i / n - y) * z;
      a[i] += x * Math.exp(-w * w);
    }
  },


   return bumps(n, m) {
    const a = [];
    for (let i = 0; i < n; ++i) a[i] = 0;
    for (let i = 0; i < m; ++i) bump(a, n);
    return a;
  };
}

这是有问题的代码。我在此特定部分遇到错误:

 },


   return bumps(n, m) {
    const a = [];
    for (let i = 0; i < n; ++i) a[i] = 0;
    for (let i = 0; i < m; ++i) bump(a, n);
    return a;
  };
}

为什么我会收到诸如',' expectedand之类的错误':' expected

标签: typescript

解决方案


推荐阅读