Skip to content

Commit c798605

Browse files
feat: add arithmetic operators
1 parent f345f7e commit c798605

File tree

2 files changed

+48
-29
lines changed

2 files changed

+48
-29
lines changed

part1 (Basics)/04_arithmetic.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Arithmetic Operators in JavaScript
2+
3+
/*
4+
+ Addition
5+
- Subtraction
6+
* Multiplication
7+
/ Division
8+
% Modulus (Remainder)
9+
** Exponentiation
10+
++ Increment
11+
-- Decrement
12+
*/
13+
14+
// Addition
15+
// Adds two numbers.
16+
console.log(5 + 3); // Output: 8
17+
18+
// Subtraction
19+
// Subtracts second number from the first.
20+
console.log(5 - 3); // Output: 2
21+
22+
// Multiplication
23+
// Multiplies two numbers.
24+
console.log(5 * 3); // Output: 15
25+
26+
// Division
27+
// Divides first number by the second.
28+
console.log(10 / 2); // Output: 5
29+
30+
// Modulus
31+
// Returns the remainder after division.
32+
console.log(10 % 3); // Output: 1
33+
34+
// Exponentiation
35+
// Raises the first number to the power of the second.
36+
console.log(2 ** 3); // Output: 8
37+
38+
// Increment
39+
// Increases a number by 1.
40+
let a = 5;
41+
a++;
42+
console.log(a); // Output: 6
43+
44+
// Decrement
45+
// Decreases a number by 1.
46+
let b = 5;
47+
b--;
48+
console.log(b); // Output: 4

part1 (Basics)/04_operators.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)