使用节点创建基于电子商务/金融的应用程序我无法确定如何在静态var var budget = 300;
中创建基本数据,然后将费用存储在数组中的对象中
var expenses = [
{name: "thingy1", price: "40"},
{name: "thingy2", price: "30"},
{name: "thingy3", price: "100"}
];
并从budget
变量中扣除价格,然后显示在模板中
p.s im使用express和swig
答案 0 :(得分:0)
你的问题有点令人困惑,所以我希望这是你想要的答案,你可能要考虑重新措辞。
var budget = 300;
var expenses = [
{name: "thingy1", price: "40"},
{name: "thingy2", price: "30"},
{name: "thingy3", price: "100"}
];
expenses.forEach(function (el) {budget -= el.price;});//Removes the price of each expense from the budget