subtract two numbers in javascript

To subtract two numbers in Javascript, you can use the subtraction operator -. Here's an example:

index.tsx
const num1 = 10;
const num2 = 5;
const result = num1 - num2;
console.log(result); // Output: 5
95 chars
5 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