How to declare numbers in JavaScript?
In JavaScript, you can declare numbers using the "number" data type. Here are some examples:
// Declaration of numbers
let num1 = 10; // integer number
let num2 = 3.14; // floating-point number
// Mathematical operations with numbers
let sum = num1 + num2; // addition
let diff = num1 - num2; // subtraction
let product = num1 * num2; // multiplication
let quotient = num1 / num2; // division
console.log(sum); // Output: 13.14
console.log(diff); // Output: 6.86
console.log(product); // Output: 31.4
console.log(quotient); // Output: 3.1847133757961785
In the example above, we declare two numbers, "num1" and "num2", and then perform various mathematical operations with them using operators such as "+" (addition), "-" (subtraction), "*" (multiplication), and "/" (division). We then log the results of these operations to the console using the "console.log()" method.