
Lessons  JavaScript Arithmetic  
Arithmetic in JavaScript is fairly simple we can add, subtract, divide and multiply our variables. In addition we also have a special modulus(%) operator that returns the division remainder. We can also store the results of our arithmetic in variables. The following example declares and defines two variables, applies different JavaScript operators on them and and stores the result in a third variable: a = 4; b = 10; c = a + b; // addition: c now contains the value 14 d = b  a; // subtraction: d now contains the value 6 e = a * b; // multiplication: e now contains the value 40 // the * operator is used for multiplication in JavaScript f = b / a; // disision: f now contains the value 2.5 g = b % a; // modulus (division remainder): g now contains the value 2 e = a++; // increment operator: increments the operand by 1 // e now contains the value 5. We can also write the above as ++a f = a; // decrement operator; a now contains the value 3 // can also be written as a
Next >>> Lesson No. 7: JavaScript If...Else

