Skip to content

Commit ecdf309

Browse files
feat: update operatorPrecedence
update some comments and code for better understanding
1 parent 59a3f6c commit ecdf309

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

part1 (Basics)/04_operatorPrecedence.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
// operatorPrecedence.js
1+
/* INFO: Operator Precedence in JavaScript
22
3-
// INFO: Operator Precedence in JavaScript
4-
5-
/*
63
Operator precedence determines the order in which parts of an expression are evaluated.
74
85
Expressions with multiple operators are evaluated based on this precedence,
@@ -21,16 +18,12 @@ let score = 2 * 3 + 2 - 1;
2118
Example 2: With parentheses (clear and recommended)
2219
let score1 = ((2 * (3 + 2)) - 1);
2320
// Evaluated as: 2 * (5) - 1 = 10 - 1 = 9
24-
25-
---
26-
27-
Console outputs:
2821
*/
2922

3023
let score = 2 * 3 + 2 - 1;
31-
let score1 = ((2 * (3 + 2)) - 1);
24+
let score1 = 2 * (3 + 2) - 1;
3225

33-
console.log(score); // Output: 7
26+
console.log(score); // Output: 7
3427
console.log(score1); // Output: 9
3528

3629
// TIP: Use parentheses to make your code easier to read and avoid unexpected results.

0 commit comments

Comments
 (0)