File tree Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change 1
- // operatorPrecedence.js
1
+ /* INFO: Operator Precedence in JavaScript
2
2
3
- // INFO: Operator Precedence in JavaScript
4
-
5
- /*
6
3
Operator precedence determines the order in which parts of an expression are evaluated.
7
4
8
5
Expressions with multiple operators are evaluated based on this precedence,
@@ -21,16 +18,12 @@ let score = 2 * 3 + 2 - 1;
21
18
Example 2: With parentheses (clear and recommended)
22
19
let score1 = ((2 * (3 + 2)) - 1);
23
20
// Evaluated as: 2 * (5) - 1 = 10 - 1 = 9
24
-
25
- ---
26
-
27
- Console outputs:
28
21
*/
29
22
30
23
let score = 2 * 3 + 2 - 1 ;
31
- let score1 = ( ( 2 * ( 3 + 2 ) ) - 1 ) ;
24
+ let score1 = 2 * ( 3 + 2 ) - 1 ;
32
25
33
- console . log ( score ) ; // Output: 7
26
+ console . log ( score ) ; // Output: 7
34
27
console . log ( score1 ) ; // Output: 9
35
28
36
29
// TIP: Use parentheses to make your code easier to read and avoid unexpected results.
You can’t perform that action at this time.
0 commit comments