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

commonly used in modern ASP.NET Core apps more examples using fetch + Blob in JavaScript to download files PDF, Excel

 Let’s explore real-world examples using the fetch + blob pattern, targeting different file types and scenarios. ✅ 1. Download Static PD...

Best for you