var valueInString = "2383";
How do I subtract 35% from number and put it back in the variable?
valueInString = valueInString - 35%
Something like the above?
Tip: You can also multiply the column to subtract a percentage. To subtract 15%, add a negative sign in front of the percentage, and subtract the percentage from 1, using the formula =1-n%, in which n is the percentage. To subtract 15%, use =1-15% as the formula.
To subtract a percent from a percent, simply ignore the percent sign and subtract the numbers as if they were whole numbers. The result will be a difference in percentage points.
To determine the percentage, we have to divide the value by the total value and then multiply the resultant by 100.
If I understand you correctly, you want to subtract 35% of valueInString
from valueInString
. So it is just some basic math.
var valueInString = "2383";
var num = parseFloat(valueInString);
var val = num - (num * .35);
console.log(val);
Math:
valueInString = valueInString * (1 - 0.35);
Shorter:
valueInString *= 1 - 0.35;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With