const x = 5; const y = 6; const z = x + y; |
Mixed Example
const price1 = 5; const price2 = 6; let total = price1 + price2; |
The const keyword is utilized to declare the variables price1 and price2, signifying that they hold constant values which cannot be altered.
On the other hand, the variable total is declared using the let keyword, indicating that its value can be modified.
When to Use var, let, or const?
|
Just Like Algebra
Similar to algebra, variables in programming store values.
let x = 5; let y = 6; |
As in algebra, variables are employed within expressions in programming.
let z = x + y; |
Based on the provided example, it can be inferred that the total is computed as 11.
Note Variables serve as containers for storing values. |