I have the following piece of code
var total = 5;
var arr = new Array("750", "400", "432", "355", "263");
id = 0;
num = 100;
var ht = 310;
var max = 750;
var cm = 20;
var bHg = 0;
var wdt = 100;
var bm = 20;
for (var i = 0; i < total; i++) {
ar = parseInt(arr[i]);
// how to rewrite these equations
**bHg = (ar * ht / max) / num * id;
printfu(cm + 50 + (i * (wdt + bm)) + bm,
cm + (ht - bHg), wdt, bHg);**
}
function printfu(a,b,c,d) {
document.write(a + b + c + d + "\n");
}
From a learning purpose, how can I write the 2 lines with a different equation to produce the same output
bHg = (ar * ht / max) / num * id;
printfu(cm + 50 + (i * (wdt + bm)) + bm, cm + (ht - bHg), wdt, bHg);
OUTPUT of the above
520 640 760 880 1000
The 2 lines can be reduced to:
i * k1 + k2wherek1andk2are constants.Complete solution: