typescript - 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;
};
}
为什么我会收到诸如',' expected
and之类的错误':' expected
?
解决方案
推荐阅读
- android - 程序类型已存在:com.google.android.gms.common.zza
- python-3.x - 如何将 python 列表插入特定的 Oracle 数据库列?
- php - 如何通过给定的行索引和列索引打印表将行值放入表中的列值在php中的json数据中
- html - 如何将单选按钮显示为
- vue.js - 新添加的数组对象的工作方式相同
- java - 我们可以将一个用于循环的变量分配给 Java 中循环内的一个值吗?
- django - Django RF - 如何在不查询 id 的情况下使用名称而不是 id 插入数据透视表?
- mysql - Write Procedure [OR] Query for Insert with Ignore using 3 Composite keys from excel or csv file in MySQL
- javascript - 如果表单为空,则阻止表单提交
- php - Laravel 表与数据透视表的关系