Bootstrap FreeKB - Node.js - Addition and Increment
Node.js - Addition and Increment

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter 8e344b in the box below so that we can be sure you are a human.