How to add two numbers in JavaScript?
Adding two numbers in JavaScript is very easy. You can use the "+" operator to add two numbers together. Here's an example:
var num1 = 5;
var num2 = 10;
var sum = num1 + num2;
console.log(sum); // Output: 15
In this example, we declare two variables, "num1" and "num2", and assign them the values of 5 and 10, respectively. We then use the "+" operator to add them together and store the result in a new variable called "sum". Finally, we use the "console.log()" method to output the value of "sum" to the console.
You can also add numbers directly in the console by typing them in with the "+" operator, like this:
5 + 10< 15
In this example, we simply type "5 + 10" into the console, and it outputs the result of 15.