Mathematical Expressions in JavaScript with examples

Mathematical operations such as addition, subtraction, multiplication, and division are commonly used in JavaScript.


let a = 10, b = 5;

let sum = a + b;          // Addition

let difference = a - b;   // Subtraction

let product = a * b;      // Multiplication

let quotient = a / b;     // Division

let modulus = a % b;      // Modulus (remainder)

let power = a ** b;       // Exponentiation


console.log(sum);         // 15

console.log(difference);  // 5

console.log(product);     // 50

console.log(quotient);    // 2

console.log(modulus);     // 0

console.log(power);       // 100000


Explanation:

  • Mathematical operations like addition (+), subtraction (-), multiplication (*), division (/), modulus (%), and exponentiation (**) are used.

No comments:

Post a Comment

JavaScript, the concept of "left-to-right" often called left-to-right evaluation or left-to-right associativity

Example 1: Basic Arithmetic Javascript  let result = 5 + 3 * 2 ; console . log (result); // Output: 11 Here’s the breakdown: The  *  (mu...

Best for you