Performing an Addition with the + Operator
Note
String concatenation is covered in more detail in Chapter 3.
Problem
You want to add some numbers together.
Solution
JavaScript has a set of recognizable math operators, including the addition (+) operator, which you can use to add numbers (or variables of numbers) together.
The Code
Listing 2-1. Performing an Addition with the + Operator
console.log(2 + 1);
var myNum = 14;
var anotherNum = 22;
console.log(anotherNum + myNum);
console.log(myNum + 0.23);
console.log(anotherNum + 16 + myNum + 14);
console.log('45' ...