Math Operators
Don't worry! Math doesn't need to be your strong-suit to learn JavaScript. However, there are operators you'll need to know to make useful programs.
JavaScript supports the following math operators:
- Add:
+ - Subtract:
- - Multiply:
* - Divide:
/
These all work how you might guess:
console.log(3 + 4); // Equals 7
console.log(5 - 1); // Equals 4
console.log(4 * 2); // Equals 8
console.log(9 / 3); // Equals 3
In the example above, each line uses a different mathematical operator to log a value to the console.
0 comments:
Post a Comment