hi all i need a javascript to do this calculatioon for me
1000 + 1000 - 10% = 1900
i have this for calculation, working example
<p id="demo"></p>
<script>
var x = 1000 + 1000 - 10 ;
document.getElementById("demo").innerHTML = x;
</script>
but i cant introduce the % behind the 10 it doesnt work
That’s an odd way of expressing it. I assume what you mean is:
1000 + ( 1000 * .9 )
1 Like
Rubble
3
Is the % a special character and would need to be escaped?
Although I would go with using a number and multiply as per @Gandalf example
Edit:
You could also leave out the parentheses as in this case 1000 + 1000 * .9 would work bit using the parentheses makes it easier to read.
yes that helps, but where does the .9 comes from how does that work
If you subtract 10% of its value from any number, what you are left with is 90% of that number. That’s 90/100, which is the same as 0.9.
Multiplying your number by 0.9 is simpler than calculating 10% and subtracting it.
2 Likes
oh i see thanks alot for the lecture didnt know that:slight_smile:
1 Like
That’s rather disturbing. It’s pretty elementary arithmetic.
oh yeah i was never good in maths, never really my thing gave me headaches:sweat_smile:
system
Closed
9
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.