PDA

View Full Version : Simple integer math?


jakie8
09-10-2008, 05:53 PM
x=5

x=x+2 (Which redefines x as 7)
x+=2 (shortcut)

x=x*3 (which defines x as 15)
x*=3 (shortcut)


My question is:

x=x-6

What would be the shortcut for that?

bsxiong
09-10-2008, 06:21 PM
x-=6
........................

jakie8
09-10-2008, 06:43 PM
Are you sure? Its not a trick question or anything?

Clueful
09-10-2008, 07:18 PM
Are you sure? Its not a trick question or anything?
It would have been quicker to test it yourself.
Paste this into your address bar and press Enter:
javascript:var x=7; x-=6; alert(x);

jakie8
09-11-2008, 12:14 AM
woah suhweet! Thank you friends!