File tree Expand file tree Collapse file tree 2 files changed +48
-29
lines changed
Expand file tree Collapse file tree 2 files changed +48
-29
lines changed Original file line number Diff line number Diff line change 1+ // Arithmetic Operators in JavaScript
2+
3+ /*
4+ + Addition
5+ - Subtraction
6+ * Multiplication
7+ / Division
8+ % Modulus (Remainder)
9+ ** Exponentiation
10+ ++ Increment
11+ -- Decrement
12+ */
13+
14+ // Addition
15+ // Adds two numbers.
16+ console . log ( 5 + 3 ) ; // Output: 8
17+
18+ // Subtraction
19+ // Subtracts second number from the first.
20+ console . log ( 5 - 3 ) ; // Output: 2
21+
22+ // Multiplication
23+ // Multiplies two numbers.
24+ console . log ( 5 * 3 ) ; // Output: 15
25+
26+ // Division
27+ // Divides first number by the second.
28+ console . log ( 10 / 2 ) ; // Output: 5
29+
30+ // Modulus
31+ // Returns the remainder after division.
32+ console . log ( 10 % 3 ) ; // Output: 1
33+
34+ // Exponentiation
35+ // Raises the first number to the power of the second.
36+ console . log ( 2 ** 3 ) ; // Output: 8
37+
38+ // Increment
39+ // Increases a number by 1.
40+ let a = 5 ;
41+ a ++ ;
42+ console . log ( a ) ; // Output: 6
43+
44+ // Decrement
45+ // Decreases a number by 1.
46+ let b = 5 ;
47+ b -- ;
48+ console . log ( b ) ; // Output: 4
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments