Added variable addition example (#23047)

Added an example showing storing values in variables before adding them. Also added syntax highlighting to original code snippet.
This commit is contained in:
kViking
2018-11-23 23:30:12 -08:00
committed by Huyen Nguyen
parent 413b0d0711
commit 7d226d0078

View File

@ -3,4 +3,15 @@ title: Add Two Numbers with JavaScript
---
JavaScript uses the `+` symbol for addition. It can also be used instead of `parseInt()` but that is beyond this.
var sum = 10 + 10;
```javascript
var sum = 10 + 10;
```
Variables can be added in a similar fashion.
```javascript
var x = 10;
var y = 10;
var z = x + y;
console.log(z); // Will print 20 to the console
```