所以我被要求重建一个网站,但是我想弄清楚下面的javascript究竟做了什么,从我在网上发现它的写得非常糟糕,可能为什么我无法弄明白
主要是'SPCost + =(nBks
完整表格的网站为http://dynamic-stationery.com/online_order_form/
var setup = 110; // film and screen
var perBk = 0.77; // printing cost per book
var thresh = 200;
var minCost = 20;
var GST = 0.1;
var numCostPBk = nums ? 1.0 : 0.0;
var SPCost;
if (CC) {
SPCost = nInks * (setup + nBks * (perBk + numCostPBk));
SPCost += nBks < thresh ? minCost : nBks * minCost / thresh;
SPCost *= 1 + GST;
SPCost = Round(SPCost);
} else {
SPCost = 0;
}
答案 0 :(得分:0)
可以读出类似这样的内容
SPCost = Number of Inks * Setup Fee (110) + Number of Books * (perBk (0.77) + numCostPBk (If numbers, 1.0 else 0.0))
The above will return a single number.
SPCost += IF number of books is less than thresh (200) then minCost else Number of books * minCost (20) / thresh (200)
SPCost += 1+ GST (0.1)
^^ Add these numbers to the first one
SPCost = round the combined totals.