I am trying to break the while loop before it goes into negative numbers, but it keeps going past 0 and showing negative numbers
The problem will be in my while loop, this is the loop
while(Math.round(housetotal)>0){
housetotal-=o*12;
zx++;
row_data.push([zx,
{v:housetotal, f:'$'+Comma(housetotal)},
]);
if(zx == year || housetotal<=0){
break
}
}
my loop works something like this.
allows
housetotal = 239,852
o = 1,438
222.596 and continue to count to -1.732 after 14 cycles
im trying to stop it in the 13th cycle, which is 15.524, so it does not go negative
in my while expression, if zx is equal to any number i, which in this case is 15, and o * 12 is any number that increases, multiplied by 12, but in this case is 1,438 x 12 = 17,256
Suzed source
share