Skip to main content

Archive

Show more

How to add two numbers in javascript

how-to-add-two-numbers-in-javascript


Question: How to add two numbers in javascript

Answer:


First: direct add two numbers.

console.log(10 + 15);

Output:

25


Second: using three variable concept.

let first = 5;
let second = 2;
let sum = first + second;
console.log(sum);

Output:

25


Third: using 'document.write()' concept.

document.write(10 + 12);

Output:

22


We try to provide you the best content, if there is any mistake in this article or there is any mistake in code, then let us know.

Comments