add two numbers in javascript

To add two numbers in JavaScript, first declare two variables and assign values to them. Then use the + (plus) operator to add the variables together. Here's an example:

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

In this example, we declare two variables num1 and num2 and assign them the values of 5 and 10 respectively. Then we declare a third variable sum and set it equal to the sum of num1 and num2. Finally, we log the value of sum to the console, which outputs 15.

gistlibby LogSnag