Node.js - Addition and Increment

by
Jeremy Canfield |
Updated: November 21 2024
| Node.js articles
Here is the most basic example of how to add two numbers in Node.js.
console.log(1 + 1)
It is much more common to store the result in a variable.
var result = (1 + 1)
console.log(result)
Which should return the following.
2
Here is an example of using addition to add two numbers.
var my_number = 1
console.log(`original my_number => ${my_number}`)
my_number = Number(my_number) + 7
console.log(`new my_number => ${my_number}`)
Which should return the following.
original my_number => 1
new my_number => 8
Did you find this article helpful?
If so, consider buying me a coffee over at