I have a variable on javascrit, initialized at 0. What I'd like to do is this :
and I'll avoid conditional statement (like if/else) to check what the value is.
I think I just do it with some matematic operation; I thought to a NOT operation, but I don't know how to do that operation without
For doing sums you can use various symbols: add (“ + ”), subtract (“ - ”), divide (“ / ”) and multiply (“ * ”). Mathematical symbols are called operators; that is, they operate on some data.
JavaScript has a built-in calculator, and mathematical operations can be done directly in the console. We can do some simple addition with numbers, for example adding 10 and 20 , using the plus sign ( + ).
Arithmetic operators are addition(+), subtraction(-), multiplication(*) and division(/). The + and - operators can also be used in date arithmetic. Returns the integer remainder of a division. For example, 17 % 5 = 2 because the remainder of 17 divided by 5 is 2.
x = 1-x;
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