To add two numbers in JavaScript, you can use the +
operator. Here's an example:
index.tsx84 chars5 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