-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay 2.js
105 lines (45 loc) · 2.09 KB
/
Day 2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Activity 1: Arithmetic Operations
//Task 1: Add two numbers and log the result to the console.
let a = 5;
let b = 10;
console.log("Sum:", a + b);
//Task 2: Subtract two numbers and log the result to the console.
console.log("Difference:", a - b);
//Task 3: Multiply two numbers and log the result to the console.
console.log("Product:", a * b);
//Task 4: Divide two numbers and log the result to the console.
console.log("Quotient:", a / b);
//Task 5: Find the remainder when one number is divided by another and log the result to the console.
console.log("Remainder:", a % b);
// Activity 2: Assignment Operators
//Task 6: Use the `+=` operator to add a number to a variable and log the result to the console.
let c = 20;
c += 10;
console.log("c after += 10:", c);
//Task 7: Use the `-=` operator to subtract a number from a variable and log the result to the console.
c -= 5;
console.log("c after -= 5:", c);
// Activity 3: Comparison Operators
//Task 8: Compare two numbers using `>` and `<` and log the result to the console.
console.log("a > b:", a > b);
console.log("a < b:", a < b);
//Task 9: Compare two numbers using `>=` and `<=` and log the result to the console.
console.log("a >= b:", a >= b);
console.log("a <= b:", a <= b);
//Task 10:Compare two numbers using `==` and `===` and log the result to the console.
console.log("a == b:", a == b);
console.log("a === b:", a === b);
//Activity 4: Logical Operators
//Task 11 Use the `&&` operator to combine two conditions and log the result to the console.
let x = true;
let y = false;
console.log("x && y:", x && y);
//Task 12: Use the `||` operator to combine two conditions and log the result to the console.
console.log("x || y:", x || y);
//Task 13: Use the `!` operator to negate a condition and log the result to the console.
console.log("!x:", !x);
//Activity 5: Ternary Operator
//Task 14: Use the ternary operator to check if a number is positive or negative and log the result to the console.
let number = -10;
let result = (number >= 0) ? "Positive" : "Negative";
console.log("The number is:", result);