【发布时间】:2020-10-11 02:54:18
【问题描述】:
这是我第一次使用 javascript。
我无法将人员插入表中,有人可以帮我吗? 所以,我想做一个简单的函数,我可以在表中插入一个人,将名称和价格插入到带有二维数组的菜单中,并验证表是否已满,你不能插入到对象数组中。
这是我的代码
var d = new Date;
dformat = [d.getMonth() + 1,
d.getDate(),
d.getFullYear()
].join('/') + ' ' + [d.getHours(),
d.getMinutes(),
d.getSeconds()
].join(':');
function custDine([
[name, price]
]) {
this.table = new Array(5);
this.date = dformat;
this.menu = new Array(name, price);
}
function addCust([
[name, price]
]) {
customer.push(new custDine([
[name, price]
]));
}
addCust([
["Pizza", 50000],
["max", 60000]
]);
console.log(customer);
the final output should be like this:
[
table,
time,
menu: [
name,
price
], [
name,
price
], [
name,
price
]
]
【问题讨论】:
-
如果包含最终输出就很容易理解了。谢谢。
-
最终输出应该是[table, time, menu: [name, price], [name, price], [name, price]]
标签: javascript arrays object multidimensional-array