mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-22 21:08:12 +08:00
fix(curriculum): misleading explanation of compound assignment operators (#65751)
Co-authored-by: SilentDeath53 <SilentDeath53@users.noreply.github.com>
This commit is contained in:
parent
41a1c78e84
commit
d453de6fda
@ -7,7 +7,7 @@ dashedName: what-are-compound-assignment-operators-in-javascript-and-how-do-they
|
||||
|
||||
# --interactive--
|
||||
|
||||
In JavaScript, all arithmetic operators have a compound assignment form. Compound assignment operators allow you to perform a mathematical operation and reassign the result back to the variable in one line of code. Instead of writing something like this:
|
||||
In JavaScript, all arithmetic operators have a compound assignment form. Compound assignment operators provide a concise shorthand for an operation on a variable followed by storing the result in that same variable. They combine the operation and assignment into a shorter form like `x += y`, which is equivalent to writing `x = x + y` but without repeating the variable name. Instead of writing something like this:
|
||||
|
||||
:::interactive_editor
|
||||
|
||||
@ -126,7 +126,7 @@ Think about how to combine mathematical operations and reassignment.
|
||||
|
||||
---
|
||||
|
||||
Perform a mathematical operation and reassign the result to the variable in one line of code.
|
||||
Provide a shorter way to perform an operation on a variable and assign the result back to that same variable.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user