Attach values to variables and add them together:

<!DOCTYPE html>
<html>
    <body>
        <script>
           var a = 10;
           var b = 20;
           document.write(a+b); 
           document.write(a*b); 
        </script>
    </body>
</html>

Output:

30
200

(=) assign is called the assignment operator

(+) assign is called the addition operator

(*) assign is called the multiplication operator


JavaScript Arithmetic Operators


Operator Description
+ Addition
- Subtraction
* Multiplication
** Exponentiation
/ Division
% Modulus (Division Remainder)
++ Increment
-- Decrement

JavaScript String Operators

The + operator can additionally be used to add (concatenate) strings.

<!DOCTYPE html>
<html>
    <body>
        <script>
            var txt1 = "Rathoji";
            var txt2 = "Tutorial";
            var txt3 = txt1 + " " + txt2;
            document.write(txt3);
        </script>
    </body>
</html>


Output:

Rathorji Tutorial