The Addition Operator (+
) adds numbers:
Example :
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arithmetic</h1>
<h2>The + Operator</h2>
<p id=”demo”></p>
<script>
let x = 5;
let y = 2;
let z = x + y;
document.getElementById(“demo”).innerHTML = z;
</script>
</body>
</html>
Output
JavaScript Arithmetic
The + Operator
7
Description :
In JavaScript, addition is an arithmetic operation used to add numbers or concatenate strings. The +
operator performs this operation.