how to add two number in javascript

To add two numbers in JavaScript, you can use the + operator. Here's an example:

index.tsx
let num1 = 10;
let num2 = 5;
let sum = num1 + num2;
console.log(sum); // Output: 15
84 chars
5 lines

In this example, we've declared two variables num1 and num2 with the values 10 and 5 respectively. We then added them together using the + operator and stored the result in a variable sum. Finally, we used the console.log() method to print the value of sum to the console. The output of this code will be 15.

gistlibby LogSnag