How to use Addition Assignment (+=) Operator In Javascript
In this approach we use Addition Assignment (+=) operator in which operator Sums up left and right operand values and then assigns the result to the left operand.
Syntax:
Y += 1 gives Y = Y + 1
Example: In this example we are using the above-explained approach.
let num1 = 15;
let num2 = 10;
// Equivalent to num1 = num1 + num2
num1 += num2;
console.log("Sum of the given number is :", num1);
Output
Sum of the given number is : 25
JavaScript Program to Add Two Numbers
We will explore how to add two numbers in JavaScript. Adding two numbers in JavaScript means combining numeric values together using arithmetic addition, which gives us their total sum.
There are several methods that can be used to Add Two Numbers in JavaScript, which are listed below:
Table of Content
- Using + Operator
- Using function
- Using Arrow function
- Using Addition Assignment (+=) Operator