How to perform arithmetic operations in JavaScript?

To perform arithmetic operations in JavaScript, you can use the following operators:

  1. Addition (+): Adds two numbers or concatenates two strings.
let sum = 5 + 3; // 8 let fullName = "John" + " " + "Doe"; // "John Doe"
  1. Subtraction (-): Subtracts one number from another.
let difference = 10 - 5; // 5
  1. Multiplication (*): Multiplies two numbers.
let product = 4 * 6; // 24
  1. Division (/): Divides one number by another.
let quotient = 12 / 3; // 4
  1. Modulo (%): Returns the remainder of the division of one number by another.
let remainder = 10 % 3; // 1
  1. Exponentiation (**): Raises a number to the power of another number.
let power = 2 ** 3; // 8

You can also combine these operators to perform more complex arithmetic operations. Keep in mind the operator precedence and use parentheses to group operations if necessary.