To subtract two numbers in Javascript, you can use the subtraction operator -
. Here's an example:
index.tsx95 chars5 lines
In this example, we declare two variables num1
and num2
and assign them the values 10
and 5
respectively. We then subtract num2
from num1
using the -
operator and store the result in a variable called result
. Finally, we print the value of result
to the console using console.log()
.
The output of this code would be 5
, which is the result of subtracting num2
from num1
.
gistlibby LogSnag