├── .gitignore ├── Day01 ├── Task.md └── index.js ├── Day02 ├── Task.md └── index.js ├── Day03 ├── Task.md └── index.js ├── Day04 ├── Task.md └── index.js ├── Day05 ├── Task.md └── index.js ├── Day06 ├── Task.md └── index.js ├── Day07 ├── Task.md └── index.js ├── Day08 ├── Task.md └── index.js ├── Day09 ├── Activity-1.html ├── Activity-2.html ├── Activity-3.html ├── Activity-4.html ├── Activity-5.html ├── Task.md └── rose.jpeg ├── Day10 ├── Activity-1.html ├── Activity-2.html ├── Activity-3.html ├── Activity-4.html ├── Activity-5.html └── Task.md ├── Day11 ├── Task.md └── index.js ├── Day12 ├── Task.md └── index.js ├── Day13 ├── Task.md └── index.js ├── Day14 ├── Task.md └── index.js ├── Day15 ├── Task.md └── index.js ├── Day16 ├── Task.md └── index.js ├── Day17 ├── Task.md └── index.js ├── Day18 ├── Task.md └── index.js ├── Day19 ├── Task.md └── index.js ├── Day20 ├── Activity-2 │ ├── index.html │ └── script.js ├── Activity-4 │ ├── index.html │ └── script.js ├── Task.md ├── index.js ├── node_modules │ ├── .package-lock.json │ ├── imurmurhash │ │ ├── README.md │ │ ├── imurmurhash.js │ │ ├── imurmurhash.min.js │ │ └── package.json │ ├── node-localstorage │ │ ├── CODE_OF_CONDUCT.md │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE.md │ │ ├── LocalStorage.js │ │ ├── README.md │ │ ├── SECURITY.md │ │ ├── package.json │ │ └── register.js │ ├── signal-exit │ │ ├── LICENSE.txt │ │ ├── README.md │ │ ├── dist │ │ │ ├── cjs │ │ │ │ ├── browser.d.ts │ │ │ │ ├── browser.d.ts.map │ │ │ │ ├── browser.js │ │ │ │ ├── browser.js.map │ │ │ │ ├── index.d.ts │ │ │ │ ├── index.d.ts.map │ │ │ │ ├── index.js │ │ │ │ ├── index.js.map │ │ │ │ ├── package.json │ │ │ │ ├── signals.d.ts │ │ │ │ ├── signals.d.ts.map │ │ │ │ ├── signals.js │ │ │ │ └── signals.js.map │ │ │ └── mjs │ │ │ │ ├── browser.d.ts │ │ │ │ ├── browser.d.ts.map │ │ │ │ ├── browser.js │ │ │ │ ├── browser.js.map │ │ │ │ ├── index.d.ts │ │ │ │ ├── index.d.ts.map │ │ │ │ ├── index.js │ │ │ │ ├── index.js.map │ │ │ │ ├── package.json │ │ │ │ ├── signals.d.ts │ │ │ │ ├── signals.d.ts.map │ │ │ │ ├── signals.js │ │ │ │ └── signals.js.map │ │ └── package.json │ └── write-file-atomic │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── lib │ │ └── index.js │ │ └── package.json ├── package-lock.json ├── package.json ├── scratch │ ├── myObjectKey │ ├── myStringKey │ └── username └── session │ ├── greeting │ ├── user │ └── username ├── Day21 ├── Task.md └── index.js ├── Day22 ├── Task.md └── index.js ├── Day23 ├── Task.md └── index.js ├── Day24 ├── README.md ├── Task.md ├── img │ ├── cloud.svg │ ├── day_image.svg │ ├── down.svg │ ├── night_image.svg │ └── up.svg ├── index.html ├── index.js ├── request.js └── style.css ├── Day25 ├── Task.md ├── images │ ├── screenshot-1.png │ └── screenshot-2.png ├── index.html ├── main.js ├── movie.html └── style.css ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashksaini-coder/Javascript-30Days/7eb7728f64730f08a799a566ead281758ac05413/.gitignore -------------------------------------------------------------------------------- /Day01/Task.md: -------------------------------------------------------------------------------- 1 | # JavaScript Basics: Variables and Data Types 2 | 3 | Welcome to the hands-on introduction to variables and data types in JavaScript! 🚀 4 | 5 | ## Learning Objectives 📚 6 | 7 | By the end of these activities, you will: 8 | - Know how to declare variables using `var`, `let`, and `const`. 9 | - Understand the different data types in JavaScript (number, string, boolean, object, array). 10 | - Be able to use the `typeof` operator to identify the data type of a variable. 11 | - Understand the concept of variable reassignment and the immutability of `const` variables. 12 | 13 | ## Activities 🛠️ 14 | 15 | This workshop is divided into several activities: 16 | 17 | ### Day 1: Variables and Data Types 18 | 19 | #### Activity 1: Variable Declaration ✏️ 20 | 1. **Task 1:** Declare a variable with `var`, assign a number, and log the value. 21 | 2. **Task 2:** Declare a variable with `let`, assign a string, and log the value. 22 | 23 | #### Activity 2: Constant Declaration 🔒 24 | 3. **Task 3:** Declare a constant with `const`, assign a boolean value, and log the value. 25 | 26 | #### Activity 3: Data Types 🔍 27 | 4. **Task 4:** Create variables of different data types and use `typeof` to log their types. 28 | 29 | #### Activity 4: Reassigning Variables 🔄 30 | 5. **Task 5:** Declare a variable with `let`, assign a value, reassign it, and log both values. 31 | 32 | #### Activity 5: Understanding `const` 🚫 33 | 6. **Task 6:** Try reassigning a constant and observe the error. 34 | 35 | ## Feature Requests (Optional) 🎨 36 | 37 | - Create a script that logs the value and type of different data type variables. 38 | - Write a script that demonstrates the difference between `let` and `const` reassignment. 39 | 40 | ## Tasks/Activities📄:- 41 | 42 | ### Activity 1: Variable Declaration 43 | - [X] Task 1: Using var 44 | - [X] Task 2: Using let 45 | 46 | 47 | ### Activity 2: Constant Declaration 48 | - [X] Task 3: Using const 49 | 50 | 51 | ### Activity 3: Data Types 52 | - [X] Task 4: Different data types 53 | 54 | 55 | ### Activity 4: Reassigning Variables 56 | - [X] Task 5: Reassigning let variables 57 | 58 | 59 | ### Activity 5: Understanding `const` 60 | - [X] Task 6: Attempting to reassign const variable -------------------------------------------------------------------------------- /Day01/index.js: -------------------------------------------------------------------------------- 1 | // Task 1: Using var 2 | var num = 42; 3 | console.log("The value of the variable 'num' is:-" + num); 4 | 5 | console.log("\n"); 6 | // Task 2: Using let 7 | let greeting = "Hello, world!"; 8 | console.log("The string is:- " + greeting); 9 | 10 | console.log("\n"); 11 | // Task 3: Using const 12 | const isLearning = true; 13 | console.log("The value of `isLearning` is:- " + isLearning); 14 | 15 | console.log("\n"); 16 | // Task 4: Different data types 17 | let number = 10; 18 | let text = "JavaScript"; 19 | let isTrue = false; 20 | let person = { name: "John", age: 30 }; 21 | let numbers = [1, 2, 3, 4]; 22 | 23 | console.log("The type of the object is:- " + typeof number); // Output: number 24 | console.log("The type of the object is:- " + typeof text); // Output: string 25 | console.log("The type of the object is:- " + typeof isTrue); // Output: boolean 26 | console.log("The type of the object is:- " + typeof person); // Output: object 27 | console.log("The type of the object is:- " + typeof numbers); // Output: object (arrays are objects in JavaScript) 28 | 29 | console.log("\n"); 30 | // Task 5: Reassigning let variable 31 | let language = "JavaScript"; 32 | console.log("The language is:- " + language); // Output: JavaScript 33 | language = "Python"; 34 | console.log("The language is:- " + language); // Output: Python 35 | 36 | console.log("\n"); 37 | // Task 6: Attempting to reassign const variable 38 | const pi = 3.14; 39 | console.log("The value of 'pi' is:- " + pi); // Output: 3.14 40 | // pi = 3.14159; // Uncommenting this line will cause an error -------------------------------------------------------------------------------- /Day02/Task.md: -------------------------------------------------------------------------------- 1 | # Day 2: Operators 2 | 3 | Welcome to Day 2 of our JavaScript workshop! Today, we will explore various operators in JavaScript. 🎉 4 | 5 | ## Learning Objectives 📚 6 | 7 | By the end of these activities, you will: 8 | - Understand and use arithmetic operators to perform basic calculations. 9 | - Use assignment operators to modify variable values. 10 | - Compare values using comparison operators. 11 | - Combine conditions using logical operators. 12 | - Use the ternary operator for concise conditional expressions. 13 | 14 | ## Tasks/Activities📄:- 15 | 16 | This workshop is divided into several activities: 17 | 18 | ### Activity 1: Arithmetic Operations ➕➖✖️➗ 19 | - [X] **Task 1:** Write a program to add two numbers and log the result to the console. 20 | - [X] **Task 2:** Write a program to subtract two numbers and log the result to the console. 21 | - [X] **Task 3:** Write a program to multiply two numbers and log the result to the console. 22 | - [X] **Task 4:** Write a program to divide two numbers and log the result to the console. 23 | - [X] **Task 5:** Write a program to find the remainder when one number is divided by another and log the result to the console. 24 | 25 | ### Activity 2: Assignment Operators ✏️ 26 | 27 | - [X] **Task 6:** Use the `+=` operator to add a number to a variable and log the result to the console. 28 | - [X] **Task 7:** Use the `-=` operator to subtract a number from a variable and log the result to the console. 29 | 30 | ### Activity 3: Comparison Operators 🔍 31 | 32 | - [X] **Task 8:** Write a program to compare two numbers using `==` and `!=` and log the result to the console. 33 | - [X] **Task 9:** Write a program to compare two numbers using `>` and `<` and log the result to the console. 34 | - [X] **Task 10:** Write a program to compare two numbers using `<=` and `>=` and log the result to the console. 35 | 36 | ### Activity 4: Logical Operators 🔗 37 | 38 | - [X] **Task 11:** Write a program that uses the `&&` operator to combine two conditions and log the result to the console. 39 | - [X] **Task 12:** Write a program that uses the `||` operator to combine two conditions and log the result to the console. 40 | - [X] **Task 13:** Write a program that uses the `!` operator to negate a condition and log the result to the console. 41 | 42 | ### Activity 5: Ternary Operator ❓ 43 | 44 | - [X] **Task 14:** Write a program that uses the ternary operator to check if a number is positive or negative and log the result to the console. 45 | 46 | ## Feature Requests (Optional) 🎨 47 | 48 | - **Arithmetic Operations Script:** Write a script that performs basic arithmetic operations (addition, subtraction, multiplication, division, remainder) on two numbers and logs the results. 49 | - **Comparison and Logical Operators Script:** Create a script that compares two numbers using different comparison operators and combines conditions using logical operators, logging the results. 50 | - **Ternary Operator Script:** Write a script that uses the ternary operator to determine if a number is positive or negative and logs the result. 51 | 52 | Happy coding! 💻✨ -------------------------------------------------------------------------------- /Day02/index.js: -------------------------------------------------------------------------------- 1 | console.log("-------------------------------------------------"); 2 | console.log("Activity 1: "); 3 | 4 | // Task 1: Addition 5 | let a = 5; 6 | let b = 10; 7 | console.log(a + b); // Output: 15 8 | 9 | // Task 2: Subtraction 10 | console.log(a - b); // Output: -5 11 | 12 | // Task 3: Multiplication 13 | console.log(a * b); // Output: 50 14 | 15 | // Task 4: Division 16 | console.log(b / a); // Output: 2 17 | 18 | // Task 5: Remainder 19 | console.log(b % a); // Output: 0 20 | 21 | console.log("-------------------------------------------------"); 22 | console.log("Activity 2: "); 23 | 24 | // Task 6: Using += 25 | let x = 10; 26 | x += 5; 27 | console.log(x); // Output: 15 28 | 29 | // Task 7: Using -= 30 | x -= 3; 31 | console.log(x); // Output: 12 32 | 33 | console.log("-------------------------------------------------"); 34 | console.log("Activity 3: "); 35 | 36 | // Task 8: Using == and != 37 | console.log(a == b); // Output: false 38 | console.log(a != b); // Output: true 39 | 40 | // Task 9: Using > and < 41 | console.log(a > b); // Output: false 42 | console.log(a < b); // Output: true 43 | 44 | // Task 10: Using <= and >= 45 | console.log(a <= b); // Output: true 46 | console.log(a >= b); // Output: false 47 | 48 | console.log("-------------------------------------------------"); 49 | console.log("Activity 4: "); 50 | 51 | // Task 11: Using && 52 | let isAdult = true; 53 | let hasID = false; 54 | console.log(isAdult && hasID); // Output: false 55 | 56 | // Task 12: Using || 57 | console.log(isAdult || hasID); // Output: true 58 | 59 | // Task 13: Using ! 60 | console.log(!isAdult); // Output: false 61 | console.log(!hasID); // Output: true 62 | 63 | console.log("-------------------------------------------------"); 64 | console.log("Activity 5: "); 65 | 66 | // Task 14: Using ternary operator 67 | let number = -5; 68 | let result = (number >= 0) ? "Positive" : "Negative"; 69 | console.log(result); // Output: Negative 70 | console.log("-------------------------------------------------"); -------------------------------------------------------------------------------- /Day03/Task.md: -------------------------------------------------------------------------------- 1 | # Day 3: Control Structures 2 | 3 | Welcome to Day 3 of our JavaScript workshop! Today, we will delve into control structures, which allow us to control the flow of our programs. 🎉 4 | 5 | ## Learning Objectives 📚 6 | 7 | By the end of these activities, you will: 8 | - Implement and understand basic if-else control flow. 9 | - Use nested if-else statements to handle multiple conditions. 10 | - Utilize switch cases for control flow based on specific values. 11 | - Apply the ternary operator for concise condition checking. 12 | - Combine multiple conditions to solve more complex problems. 13 | 14 | ## Activities 🛠️ 15 | 16 | This workshop is divided into several activities: 17 | 18 | ### Activity 1: If-Else Statements :sparkles: 19 | 20 | - [X] **Task 1:** Write a program to check if a number is positive, negative, or zero, and log the result to the console. 21 | - [X] **Task 2:** Write a program to check if a person is eligible to vote (age >= 18) and log the result to the console. 22 | 23 | ### Activity 2: Nested If-Else Statements 🔄 24 | 25 | - [X] **Task 3:** Write a program to find the largest of three numbers using nested if-else statements. 26 | 27 | ### Activity 3: Switch Case 🔀 28 | 29 | - [X] **Task 4:** Write a program that uses a switch case to determine the day of the week based on a number (1-7) and log the day name to the console. 30 | - [X] **Task 5:** Write a program that uses a switch case to assign a grade ('A', 'B', 'C', 'D', 'F) based on a score and log the grade to the console. 31 | 32 | ### Activity 4: Conditional (Ternary) Operator ❓ 33 | 34 | - [X] **Task 6:** Write a program that uses the ternary operator to check if a number is even or odd and log the result to the console. 35 | 36 | ### Activity 5: Combining Conditions 🔗 37 | 38 | - [X] **Task 7:** Write a program to check if a year is a leap year using multiple conditions (divisible by 4, but not 100 unless also divisible by 400) and log the result to the console. 39 | 40 | ## Feature Requests (Optional) 🎨 41 | 42 | 1. **Number Check Script:** Write a script that checks if a number is positive, negative, or zero using if-else statements and logs the result. 43 | 2. **Voting Eligibility Script:** Write a script that checks if a person is eligible to vote (age >= 18) and logs the result. 44 | 3. **Day of the Week Script:** Write a script that uses a switch case to determine the day of the week based on a number (1-7) and logs the day name. 45 | 4. **Grade Assignment Script:** Create a script that uses a switch case to assign a grade based on a score and logs the grade. 46 | 5. **Leap Year Check Script:** Write a script that checks if a year is a leap year using multiple conditions and logs the result. 47 | 48 | Happy coding! 💻✨ -------------------------------------------------------------------------------- /Day04/Task.md: -------------------------------------------------------------------------------- 1 | # Day 4: Loops 2 | 3 | Welcome to Day 4 of our JavaScript workshop! Today, we will dive into loops, which allow us to repeat blocks of code efficiently. 🎉 4 | 5 | ## Learning Objectives 📚 6 | 7 | By the end of these activities, you will: 8 | - Understand and use `for` loops to iterate over a sequence of numbers. 9 | - Utilize `while` loops for iteration based on a condition. 10 | - Apply `do...while` loops to ensure the loop body is executed at least once. 11 | - Implement nested loops to solve more complex problems. 12 | - Use loop control statements (`break` and `continue`) to control the flow of loops. 13 | 14 | ## Activities 🛠️ 15 | 16 | This workshop is divided into several activities: 17 | 18 | ### Activity 1: For Loop 🔁 19 | 20 | - [X] **Task 1:** Write a program to print numbers from 1 to 10 using a for loop. 21 | - [X] **Task 2:** Write a program to print the multiplication table of 5 using a for loop. 22 | 23 | ### Activity 2: While Loop 🔄 24 | 25 | - [X] **Task 3:** Write a program to calculate the sum of numbers from 1 to 10 using a while loop. 26 | - [X] **Task 4:** Write a program to print numbers from 10 to 1 using a while loop. 27 | 28 | ### Activity 3: Do...While Loop 🔂 29 | 30 | - [X] **Task 5:** Write a program to print numbers from 1 to 5 using a do...while loop. 31 | - [X] **Task 6:** Write a program to calculate the factorial of a number using a do...while loop. 32 | 33 | ### Activity 4: Nested Loops 🔀 34 | 35 | - [X] **Task 7:** Write a program to print a pattern using nested for loops: 36 | ``` 37 | * 38 | ** 39 | *** 40 | **** 41 | ***** 42 | ``` 43 | 44 | ### Activity 5: Loop Control Statements ⏭️ 45 | 46 | - [X] **Task 8:** Write a program to print numbers from 1 to 10, but skip the number 5 using the `continue` statement. 47 | - [X] **Task 9:** Write a program to print numbers from 1 to 10, but stop the loop when the number is 7 using the `break` statement. 48 | 49 | ## Feature Requests (Optional) 🎨` 50 | 51 | 1. **Number Printing Script:** Write a script that prints numbers from 1 to 10 using a for loop and a while loop. 52 | 2. **Multiplication Table Script:** Create a script that prints the multiplication table of 5 using a for loop. 53 | 3. **Pattern Printing Script:** Write a script that prints a pattern of stars using nested loops. 54 | 4. **Sum Calculation Script:** Write a script that calculates the sum of numbers from 1 to 10 using a while loop. 55 | 5. **Factorial Calculation Script:** Create a script that calculates the factorial of a number using a do...while loop. 56 | -------------------------------------------------------------------------------- /Day04/index.js: -------------------------------------------------------------------------------- 1 | console.log("-------------------------------------------------"); 2 | console.log("Activity 1: "); 3 | 4 | // Task 1: Write a program to print numbers from 1 to 10 using a for loop. 5 | 6 | loop = () => { 7 | for (let i = 1; i <= 10; i++) { 8 | console.log(i); 9 | } 10 | } 11 | 12 | loop(); 13 | 14 | // Task 2: Write a program to print the multiplication table of 5 using a for loop 15 | 16 | table = () => { 17 | for(let i=0; i<=10; i++){ 18 | console.log(5*i); 19 | } 20 | } 21 | 22 | table(); 23 | 24 | console.log("-------------------------------------------------"); 25 | console.log("Activity 2: "); 26 | 27 | // Task 3: Write a program to calculate the sum of numbers from 1 to 10 using a while loop. 28 | 29 | function sum(){ 30 | let i = 1; 31 | let sum = 0; 32 | while(i<=10){ 33 | sum += i; 34 | i++; 35 | } 36 | console.log(sum); 37 | } 38 | 39 | sum(); 40 | 41 | // Task 4: Write a program to print numbers from 10 to 1 using a while loop 42 | 43 | function print(){ 44 | let i = 10; 45 | while(i>=1){ 46 | console.log(i); 47 | i--; 48 | } 49 | 50 | } 51 | 52 | print(); 53 | 54 | console.log("-------------------------------------------------"); 55 | console.log("Activity 3: "); 56 | 57 | // Task 5: Write a program to print numbers from 1 to 5 using a do...while loop 58 | 59 | function printNumbers(){ 60 | let i = 1; 61 | do{ 62 | console.log(i); 63 | i++; 64 | }while(i<=5); 65 | } 66 | 67 | printNumbers(); 68 | 69 | // Task 6: Write a program to calculate the factorial of a number using a do...while loop 70 | 71 | const factorial = (n) => { 72 | let fact = 1; 73 | let i = 1; 74 | do { 75 | fact *= i; 76 | i++; 77 | } while (i <= n); 78 | console.log(fact); 79 | } 80 | 81 | factorial(5); 82 | 83 | console.log("-------------------------------------------------"); 84 | console.log("Activity 4: "); 85 | 86 | // Write a program to print a pattern using nested for loops: 87 | 88 | // * 89 | // ** 90 | // *** 91 | // **** 92 | // ***** 93 | 94 | function pattern(){ 95 | for (let i = 1; i <= 5; i++) { 96 | let pattern = ''; 97 | for (let j = 1; j <= i; j++) { 98 | pattern += '*'; 99 | } 100 | console.log(pattern); 101 | } 102 | } 103 | 104 | pattern(); 105 | 106 | 107 | console.log("-------------------------------------------------"); 108 | console.log("Activity 5: "); 109 | 110 | // Task 8: Write a program to print numbers from 1 to 10, but skip the number 5 using the `continue` statement. 111 | 112 | function skip(){{ 113 | for(let i=1; i<=10; i++){ 114 | if(i==5){ 115 | continue; 116 | } 117 | console.log(i); 118 | } 119 | } 120 | } 121 | 122 | skip(); 123 | 124 | // Task 9: Write a program to print numbers from 1 to 10, but stop the loop when the number is 7 using the `break` statement. 125 | 126 | function stop(){ 127 | for(let i=1; i<=10; i++){ 128 | if(i==7){ 129 | break; 130 | } 131 | console.log(i); 132 | } 133 | } 134 | 135 | stop(); -------------------------------------------------------------------------------- /Day05/Task.md: -------------------------------------------------------------------------------- 1 | # Day 5: Functions 2 | 3 | Welcome to Day 5 of our JavaScript workshop! Today, we will explore functions, one of the most powerful features in JavaScript. 🎉 4 | 5 | ## Learning Objectives 📚 6 | 7 | By the end of these activities, you will: 8 | - Understand and define functions using function declarations, expressions, and arrow functions. 9 | - Use function parameters and default values effectively. 10 | - Create and utilize higher-order functions. 11 | - Apply functions to solve common problems and perform calculations. 12 | - Enhance code reusability and organization using functions. 13 | 14 | ## Activities 🛠️ 15 | 16 | This workshop is divided into several activities: 17 | 18 | ### Activity 1: Function Declaration 🔍 19 | 20 | - [X] **Task 1:** Write a function to check if a number is even or odd and log the result to the console. 21 | - [X] **Task 2:** Write a function to calculate the square of a number and return the result. 22 | 23 | ### Activity 2: Function Expression 💡 24 | 25 | - [X] **Task 3:** Write a function expression to find the maximum of two numbers and log the result to the console. 26 | - [X] **Task 4:** Write a function expression to concatenate two strings and return the result. 27 | 28 | ### Activity 3: Arrow Functions 🎯 29 | 30 | - [X] **Task 5:** Write an arrow function to calculate the sum of two numbers and return the result. 31 | - [X] **Task 6:** Write an arrow function to check if a string contains a specific character and return a boolean value. 32 | 33 | ### Activity 4: Function Parameters and Default Values 🛠️ 34 | 35 | - [X] **Task 7:** Write a function that takes two parameters and returns their product. Provide a default value for the second parameter. 36 | - [X] **Task 8:** Write a function that takes a person's name and age and returns a greeting message. Provide a default value for the age. 37 | 38 | ### Activity 5: Higher-Order Functions 🚀 39 | 40 | - [X] **Task 9:** Write a higher-order function that takes a function and a number, and calls the function that many times. 41 | - [X] **Task 10:** Write a higher-order function that takes two functions and a value, applies the first function to the value, and then applies the second function to the result. 42 | 43 | ## Feature Requests (Optional) 🎨 44 | 45 | 1. **Even or Odd Function Script:** Write a script that includes a function to check if a number is even or odd and logs the result. 46 | 2. **Square Calculation Function Script:** Create a script that includes a function to calculate the square of a number and returns the result. 47 | 3. **Concatenation Function Script:** Write a script that includes a function expression to concatenate two strings and returns the result. 48 | 4. **Sum Calculation Arrow Function Script:** Create a script that includes an arrow function to calculate the sum of two numbers and returns the result. 49 | 5. **Higher-Order Function Script:** Write a script that includes a higher-order function to apply a given function multiple times. 50 | 51 | 52 | Happy coding! 💻✨ -------------------------------------------------------------------------------- /Day05/index.js: -------------------------------------------------------------------------------- 1 | console.log("-------------------------------------------------"); 2 | console.log("Activity 1: "); 3 | 4 | // Write a function to check if a number is even or odd and log the result to the console. 5 | function checker(num){ 6 | if (num % 2 ==0) console.log(num + " is even."); 7 | else console.log(num + " is odd."); 8 | } 9 | 10 | checker(2); 11 | checker(3); 12 | 13 | // Task 2: Write a function to calculate the square of a number and return the result. 14 | 15 | function square(num){ 16 | console.log("Square of " + num + " is " + num*num); 17 | } 18 | 19 | square(2); 20 | square(3); 21 | 22 | 23 | console.log("-------------------------------------------------"); 24 | console.log("Activity 2: "); 25 | 26 | // Task 3: Write a function expression to find the maximum of two numbers and log the result to the console. 27 | 28 | let max = function(num1, num2){ 29 | if (num1 > num2) console.log(num1 + " is greater than " + num2); 30 | else console.log(num2 + " is greater than " + num1); 31 | } 32 | 33 | max(2,3); 34 | 35 | 36 | // Task 4: Write a function expression to concatenate two strings and return the result. 37 | 38 | let concat = function(str1, str2){ 39 | return str1 + " " + str2; 40 | } 41 | 42 | console.log(concat("Hello", "World")); 43 | 44 | console.log("-------------------------------------------------"); 45 | console.log("Activity 3: "); 46 | 47 | // Task 4: Write an arrow function to calculate the sum of two numbers and return the result. 48 | 49 | sum = (num1, num2) => num1 + num2; 50 | 51 | console.log(sum(2,3)); 52 | 53 | // Task 5: Write an arrow function to check if a string contains a specific character and return a boolean value. 54 | 55 | contains = (str, char) => str.includes(char); 56 | 57 | console.log(contains("Hello", "e")); 58 | console.log(contains("Hello", "a")); 59 | 60 | 61 | 62 | console.log("-------------------------------------------------"); 63 | console.log("Activity 4: "); 64 | 65 | // Task 7: Write a function that takes two parameters and returns their product. Provide a default value for the second parameter. 66 | 67 | function product(num1, num2 = 2){ 68 | return num1 * num2; 69 | } 70 | 71 | console.log(product(5,3)); 72 | console.log(product(5)); 73 | 74 | // Task 8: Write a function that takes a person's name and age and returns a greeting message. Provide a default value for the age. 75 | 76 | function greet(str, age = 18){ 77 | return "Hello " + str + ". You are " + age + " years old."; 78 | } 79 | 80 | console.log(greet("Deepanshu", 20)); 81 | console.log(greet("Paras")); 82 | 83 | console.log("-------------------------------------------------"); 84 | console.log("Activity 5: "); 85 | 86 | // Task 9: Write a higher-order function that takes a function and a number, and calls the function that many times. 87 | 88 | function repeat(func, num){ 89 | for (let i=0; i num*2); 39 | console.log("The new mapped Array is:- "+mapArr); 40 | 41 | // Task 8: Use the `filter` method to create a new array with only even numbers and log the new array. 42 | 43 | let filterarr = arr.filter((num) => num%2 == 0); 44 | console.log("The new filtered Array is:- "+filterarr); 45 | 46 | // Task 9: Use the `reduce` method to calculate the sum of all numbers in the array and log the result. 47 | 48 | let reducearr = arr.reduce((acc, num) => acc+num, 0); 49 | console.log("The sum of all the numbers in the array is:- "+reducearr); 50 | 51 | 52 | console.log("-------------------------------------------------"); 53 | console.log("Activity 4: "); 54 | 55 | // Task 10: Use a `for` loop to iterate over the array and log each element to the console. 56 | console.log("Using for loop:- "); 57 | for(let i=0; i { 64 | console.log("Element at index "+index+" is:- "+num); 65 | }); 66 | 67 | console.log("-------------------------------------------------"); 68 | console.log("Activity 5: "); 69 | 70 | // Task 12: Create a two-dimensional array (matrix) and log the entire array to the console. 71 | let matrix = [[1,2,3], 72 | [4,5,6], 73 | [7,8,9]]; 74 | console.log("The Matrix is:- "+matrix); 75 | 76 | // Task 13: Access and log a specific element from the two-dimensional array. 77 | console.log("The element at 2nd row and 3rd column is:- "+matrix[1][2]); 78 | console.log("The element at 3rd row and 2nd column is:- "+matrix[2][1]); 79 | 80 | console.log("-------------------------------------------------"); 81 | -------------------------------------------------------------------------------- /Day07/Task.md: -------------------------------------------------------------------------------- 1 | # Day 7: Objects 2 | 3 | Welcome to Day 7 of our JavaScript workshop! Today, we will explore objects, a core component of JavaScript programming. 📚 4 | 5 | ## Learning Objectives 📚 6 | 7 | By the end of these activities, you will: 8 | - Create and manipulate objects with properties and methods. 9 | - Understand and use the `this` keyword in object methods. 10 | - Work with nested objects and arrays of objects. 11 | - Iterate over an object's properties using loops and built-in methods. 12 | 13 | ## Activities 🛠️ 14 | 15 | This workshop is divided into several activities: 16 | 17 | ### Activity 1: Object Creation and Access 🔍 18 | 19 | - [X] **Task 1:** Create an object representing a book with properties like `title`, `author`, and `year`, and log the object to the console. 20 | - [X] **Task 2:** Access and log the `title` and `author` properties of the book object. 21 | 22 | ### Activity 2: Object Methods 💡 23 | 24 | - [X] **Task 3:** Add a method to the book object that returns a string with the book's title and author, and log the result of calling this method. 25 | - [X] **Task 4:** Add a method to the book object that takes a parameter (year) and updates the book's year property, then log the updated object. 26 | 27 | ### Activity 3: Nested Objects 🚀 28 | 29 | - [X] **Task 5:** Create a nested object representing a library with properties like `name` and `books` (an array of book objects), and log the library object to the console. 30 | - [X] **Task 6:** Access and log the name of the library and the titles of all the books in the library. 31 | 32 | ### Activity 4: The `this` Keyword 🎯 33 | 34 | - [X] **Task 7:** Add a method to the book object that uses the `this` keyword to return a string with the book's title and year, and log the result of calling this method. 35 | 36 | ### Activity 5: Object Iteration 🛠️ 37 | 38 | - [X] **Task 8:** Use a `for...in` loop to iterate over the properties of the book object and log each property and its value. 39 | - [X] **Task 9:** Use `Object.keys` and `Object.values` methods to log all the keys and values of the book object. 40 | 41 | ## Feature Requests (Optional) 🎨 42 | 43 | 1. **Book Object Script:** Write a script that creates a book object, adds methods to it, and logs its properties and method results. 44 | 2. **Library Object Script:** Create a script that defines a library object containing an array of book objects and logs the library's details. 45 | 3. **Object Iteration Script:** Write a script that demonstrates iterating over an object's properties using `for...in` loop and `Object.keys`/`Object.values`. 46 | 47 | Happy coding! 💻✨ -------------------------------------------------------------------------------- /Day07/index.js: -------------------------------------------------------------------------------- 1 | console.log("-------------------------------------------------"); 2 | console.log("Activity 1: "); 3 | 4 | // Task 1: Create an object representing a book with properties like `title`, `author`, and `year`, and log the object to the console. 5 | 6 | const book = { 7 | title: "Rich Dad Poor Dad", 8 | author: "Robert T Kiyosaki", 9 | year: "2020" 10 | }; 11 | console.log(book); 12 | 13 | // Task 2: Access and log the `title` and `author` properties of the book object. 14 | 15 | console.log("The title of the Book is:- " + book.title); 16 | console.log("The author of the book is:- " + book.author); 17 | 18 | console.log("-------------------------------------------------"); 19 | console.log("Activity 2: "); 20 | 21 | // Task 3: Add a method to the book object that returns a string with the book's title and author, and log the result of calling this method. 22 | 23 | book.bookDetails = function() { 24 | return `The book ${this.title} is written by ${this.author}.`; 25 | }; 26 | 27 | console.log(book.bookDetails()); 28 | 29 | // Task 4: Add a method to the book object that takes a parameter (year) and updates the book's year property, then log the updated object. 30 | 31 | book.updateYear = function(year) { 32 | this.year = year; 33 | return this; 34 | }; 35 | 36 | console.log(book.updateYear("2021")); 37 | 38 | console.log("-------------------------------------------------"); 39 | console.log("Activity 3: "); 40 | 41 | // Task 5: Create a nested object representing a library with properties like `name` and `books` (an array of book objects), and log the library object to the console. 42 | 43 | const library = { 44 | name: "Library of Congress", 45 | books: [ 46 | { 47 | title: "EGO is the Enemy", 48 | } 49 | ] 50 | }; 51 | 52 | console.log(library); 53 | 54 | // Task 6: Access and log the name of the library and the titles of all the books in the library. 55 | 56 | console.log("The name of the library is:- " + library.name); 57 | console.log("The titles of the books in the library are:- " + library.books[0].title); 58 | 59 | 60 | console.log("-------------------------------------------------"); 61 | console.log("Activity 4: "); 62 | 63 | // Task 7: Add a method to the book object that uses the `this` keyword to return a string with the book's title and year, and log the result of calling this method. 64 | 65 | book.bookDetails = function() { 66 | return `The book ${this.title} was published in ${this.year}.`; 67 | }; 68 | 69 | console.log(book.bookDetails()); 70 | 71 | console.log("-------------------------------------------------"); 72 | console.log("Activity 5: "); 73 | 74 | // Task 8: Use a `for...in` loop to iterate over the properties of the book object and log each property and its value. 75 | 76 | for (let key in book) { 77 | console.log(`${key}: ${book[key]}`); 78 | }; 79 | 80 | // Task 9: Use `Object.keys` and `Object.values` methods to log all the keys and values of the book object. 81 | 82 | console.log("This is the keys:-"+Object.keys(book)); 83 | console.log("This is the values:-"+Object.values(book)); 84 | 85 | -------------------------------------------------------------------------------- /Day08/Task.md: -------------------------------------------------------------------------------- 1 | # Day 8: ES6+ Features 🚀 2 | 3 | Welcome to Day 8 of our JavaScript workshop! Today, we will dive into some of the powerful features introduced in ES6 and beyond. 🌟 4 | 5 | ## Learning Objectives 📚 6 | 7 | By the end of these activities, you will: 8 | - Understand and use template literals for string interpolation and multi-line strings. 9 | - Apply destructuring to extract values from arrays and objects. 10 | - Utilize spread and rest operators for array manipulation and function arguments. 11 | - Define functions with default parameters. 12 | - Create objects using enhanced object literals, including methods and computed property names. 13 | 14 | ## Activities 🛠️ 15 | 16 | This workshop is divided into several activities: 17 | 18 | ### Activity 1: Template Literals ✨ 19 | 20 | - [X] **Task 1:** Use template literals to create a string that includes variables for a person's name and age, and log the string to the console. 21 | - [X] **Task 2:** Create a multi-line string using template literals and log it to the console. 22 | 23 | ### Activity 2: Destructuring 🛠️ 24 | 25 | - [X] **Task 3:** Use array destructuring to extract the first and second elements from an array of numbers and log them to the console. 26 | - [X] **Task 4:** Use object destructuring to extract the title and author from a book object and log them to the console. 27 | 28 | ### Activity 3: Spread and Rest Operators 📌 29 | 30 | - [X] **Task 5:** Use the spread operator to create a new array that includes all elements of an existing array plus additional elements, and log the new array to the console. 31 | - [X] **Task 6:** Use the rest operator in a function to accept an arbitrary number of arguments, sum them, and return the result. 32 | 33 | ### Activity 4: Default Parameters 🔧 34 | 35 | - [X] **Task 7:** Write a function that takes two parameters and returns their product, with the second parameter having a default value of 1. Log the result of calling this function with and without the second parameter. 36 | 37 | ### Activity 5: Enhanced Object Literals ⚙️ 38 | 39 | - [X] **Task 8:** Use enhanced object literals to create an object with methods and properties, and log the object to the console. 40 | - [X] **Task 9:** Create an object with computed property names based on variables and log the object to the console. 41 | 42 | ## Feature Requests (Optional) 🎨 43 | 44 | 1. **Template Literals Script:** Write a script that demonstrates the use of template literals to create and log strings with embedded variables and multi-line strings. 45 | 2. **Destructuring Script:** Create a script that uses array and object destructuring to extract values and log them. 46 | 3. **Spread and Rest Operators Script:** Write a script that demonstrates the use of the spread operator to combine arrays and the rest operator to handle multiple function arguments. 47 | 4. **Default Parameters Script:** Create a script that defines a function with default parameters and logs the results of calling it with different arguments. 48 | 5. **Enhanced Object Literals Script:** Write a script that uses enhanced object literals to create and log an object with methods and computed property names. 49 | -------------------------------------------------------------------------------- /Day08/index.js: -------------------------------------------------------------------------------- 1 | console.log("-------------------------------------------------"); 2 | console.log("Activity 1: "); 3 | 4 | // Task 1: Use template literals to create a string that includes variables for a person's name and age, and log the string to the console. 5 | 6 | let name = "John"; 7 | let age = 30; 8 | console.log(`My name is ${name} and I am ${age} years old.`); 9 | 10 | // Task 2: Create a multi-line string using template literals and log it to the console. 11 | 12 | let multiLineString = `This is a multi-line string. 13 | It is created using template literals. 14 | It is very convenient to use.`; 15 | console.log(`This is multiLineString:- ${multiLineString}`); 16 | 17 | 18 | console.log("-------------------------------------------------"); 19 | console.log("Activity 2: "); 20 | 21 | // Task 3: Use array destructuring to extract the first and second elements from an array of numbers and log them to the console. 22 | 23 | arr = [1, 2, 3, 4, 5]; 24 | let [first, second] = arr; 25 | console.log(`First element: ${first}, Second element: ${second}`); 26 | 27 | // Task 4: Use object destructuring to extract the title and author from a book object and log them to the console. 28 | 29 | let book = { 30 | title: "The Alchemist", 31 | author: "Paulo Coelho" 32 | }; 33 | 34 | let {title, author} = book; 35 | console.log(`Title: ${title}, Author: ${author}`); 36 | 37 | 38 | console.log("-------------------------------------------------"); 39 | console.log("Activity 3: "); 40 | 41 | // Task 5: Use the spread operator to create a new array that includes all elements of an existing array plus additional elements, and log the new array to the console. 42 | 43 | arr1 = [1, 2, 3]; 44 | arr2 = [4, 5, 6]; 45 | 46 | newarr = [...arr1, ...arr2]; 47 | console.log(`New Array: ${newarr}`); 48 | 49 | // Task 6: Use the rest operator in a function to accept an arbitrary number of arguments, sum them, and return the result. 50 | 51 | function sum(...theArgs) { 52 | let total = 0; 53 | for (const arg of theArgs) { 54 | total += arg; 55 | } 56 | return total; 57 | } 58 | 59 | console.log(`Sum of 1, 2, 3, 4, 5: ${sum(1, 2, 3, 4, 5)}`); 60 | 61 | 62 | console.log("-------------------------------------------------"); 63 | console.log("Activity 4: "); 64 | 65 | 66 | // Task 7: Write a function that takes two parameters and returns their product, with the second parameter having a default value of 1. Log the result of calling this function with and without the second parameter. 67 | 68 | function product(a, b = 1) { 69 | return a * b; 70 | } 71 | 72 | console.log(`Product of 5 and 2: ${product(5, 2)}`); 73 | 74 | console.log("-------------------------------------------------"); 75 | console.log("Activity 5: "); 76 | 77 | // Task 8: Use enhanced object literals to create an object with methods and properties, and log the object to the console. 78 | 79 | let person = { 80 | name: "Linus", 81 | age: 30, 82 | greet() { 83 | console.log(`Hello, my name is ${this.name} and I am ${this.age} years old.`); 84 | } 85 | }; 86 | 87 | person.greet(); 88 | 89 | // Task 9: Create an object with computed property names based on variables and log the object to the console. 90 | 91 | const prop1 = "firstName"; 92 | const prop2 = "lastName"; 93 | const prop3 = "age"; 94 | 95 | // Create an object with computed property names 96 | const details = { 97 | [prop1]: "John", 98 | [prop2]: "Doe", 99 | [prop3]: 30 100 | }; 101 | 102 | // Log the object to the console 103 | console.log(details); 104 | -------------------------------------------------------------------------------- /Day09/Activity-1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Activity-1 7 | 8 | 9 | 19 |

Original Text

20 | 21 | 22 | 23 |
24 |
25 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Day09/Activity-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Activity-2 7 | 15 | 16 | 17 |
18 | 19 | 20 |
21 | 26 | 45 | 46 | -------------------------------------------------------------------------------- /Day09/Activity-3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Activity-3 7 | 8 | 9 | 10 |

This is a Standard HTML element

11 | 12 | 13 | 14 | 21 | 22 | 23 | 34 | 35 | -------------------------------------------------------------------------------- /Day09/Activity-4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Activity-4 7 | 8 | 9 | 19 | 20 |
21 | 22 |
23 | 24 | 25 |
26 |

Click the button to add a class to this paragraph.

27 | 28 |
29 | 39 | 40 | -------------------------------------------------------------------------------- /Day09/Activity-5.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Activity-5 7 | 8 | 9 | 10 |

This is a pragraph who's content is about to be changed once the function is called on the button click.

11 |
12 | 13 | 19 | 20 | -------------------------------------------------------------------------------- /Day09/Task.md: -------------------------------------------------------------------------------- 1 | # Day 9: DOM Manipulation 🎨 2 | 3 | Welcome to Day 9 of our JavaScript workshop! Today, we will explore the Document Object Model (DOM) and learn how to interact with HTML elements using JavaScript. 🌟 4 | 5 | ## Learning Objectives 📚 6 | 7 | By the end of these activities, you will: 8 | - Select and manipulate DOM elements using JavaScript. 9 | - Create and append new elements to the DOM. 10 | - Remove elements from the DOM. 11 | - Modify attributes and classes of HTML elements. 12 | - Add and handle events to make web pages interactive. 13 | 14 | ## Activities 🛠️ 15 | 16 | This workshop is divided into several activities: 17 | 18 | ### Activity 1: Selecting and Manipulating Elements 🖱️ 19 | 20 | - [X] **Task 1:** Select an HTML element by its ID and change its text content. 21 | - [X] **Task 2:** Select an HTML element by its class and change its background color. 22 | 23 | ### Activity 2: Creating and Appending Elements 🏗️ 24 | 25 | - [X] **Task 3:** Create a new `div` element with some text content and append it to the body. 26 | - [X] **Task 4:** Create a new `li` element and add it to an existing `ul` list. 27 | 28 | ### Activity 3: Removing Elements ❌ 29 | 30 | - [X] **Task 5:** Select an HTML element and remove it from the DOM. 31 | - [X] **Task 6:** Remove the last child of a specific HTML element. 32 | 33 | ### Activity 4: Modifying Attributes and Classes 🔄 34 | 35 | - [X] **Task 7:** Select an HTML element and change one of its attributes (e.g., `src` of an `img` tag). 36 | - [X] **Task 8:** Add and remove a CSS class to/from an HTML element. 37 | 38 | ### Activity 5: Event Handling 🎯 39 | 40 | - [X] **Task 9:** Add a click event listener to a button that changes the text content of a paragraph. 41 | - [X] **Task 10:** Add a mouseover event listener to an element that changes its border color. 42 | 43 | ## Feature Requests (Optional) 🎨 44 | 45 | 1. **Text Content Manipulation Script:** Write a script that selects an HTML element by its ID and changes its text content. 46 | 2. **Element Creation Script:** Create a script that demonstrates creating a new `div` element and appending it to the body. 47 | 3. **Element Removal Script:** Write a script that selects an HTML element and removes it from the DOM. 48 | 4. **Attribute Modification Script:** Create a script that changes the attributes of an HTML element. 49 | 5. **Event Handling Script:** Write a script that adds event listeners to HTML elements to change their content or style based on user interactions. 50 | 51 | Happy coding! 💻✨ -------------------------------------------------------------------------------- /Day09/rose.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashksaini-coder/Javascript-30Days/7eb7728f64730f08a799a566ead281758ac05413/Day09/rose.jpeg -------------------------------------------------------------------------------- /Day10/Activity-1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Activity-1 7 | 8 | 9 | 10 |

The Button is not clicked

11 | 12 |
13 |
14 | 15 | Google Logo 16 | 21 | 22 | -------------------------------------------------------------------------------- /Day10/Activity-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Activity-2 7 | 8 | 9 | 38 |
39 | 40 |
41 |

Hover over me!

42 |
43 | 44 |
45 | 46 | 47 |
48 |

Hover over me!

49 |
50 |
51 | 60 | 61 | -------------------------------------------------------------------------------- /Day10/Activity-3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Activity-3 7 | 8 | 9 | 38 | 39 |

Here is the input field


40 |
41 |

You pressed this key


42 |


43 | 44 | 45 |

Here is the input field


46 |
47 |

You pressed this key


48 |

49 | 58 | 59 | -------------------------------------------------------------------------------- /Day10/Activity-4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Activity-4 7 | 8 | 9 | 12 | 13 | 14 |
15 |
16 |
17 | 18 |
19 |
20 |
21 | 22 | 28 |

The value is:

29 | 30 | 41 | 42 | -------------------------------------------------------------------------------- /Day10/Activity-5.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Activity-5 7 | 8 | 9 | 10 | 15 | 16 | 17 |
    18 |
  1. Item 1
  2. 19 |
  3. Item 2
  4. 20 |
  5. Item 3
  6. 21 |
22 | 23 | 35 | 36 | -------------------------------------------------------------------------------- /Day10/Task.md: -------------------------------------------------------------------------------- 1 | # Day 10: Event Handling 🎉 2 | 3 | Welcome to Day 10 of our JavaScript workshop! Today, we will dive into event handling, an essential skill for making web pages interactive and responsive to user actions. 🖱️💻 4 | 5 | ## Learning Objectives 📚 6 | 7 | By the end of these activities, you will: 8 | - Add and handle basic events like click, double-click, mouseover, mouseout, keydown, and keyup. 9 | - Understand and handle form events. 10 | - Implement event delegation to manage events on dynamically added elements. 11 | - Make web pages interactive by responding to various user actions. 12 | 13 | ## Activities 🛠️ 14 | 15 | This workshop is divided into several activities: 16 | 17 | ### Activity 1: Basic Event Handling 🖱️ 18 | 19 | - [X] **Task 1:** Add a click event listener to a button that changes the text content of a paragraph. 20 | - [X] **Task 2:** Add a double-click event listener to an image that toggles its visibility. 21 | 22 | ### Activity 2: Mouse Events 🐭 23 | 24 | - [X] **Task 3:** Add a mouseover event listener to an element that changes its background color. 25 | - [X] **Task 4:** Add a mouseout event listener to an element that resets its background color. 26 | 27 | ### Activity 3: Keyboard Events 🎹 28 | 29 | - [X] **Task 5:** Add a keydown event listener to an input field that logs the key pressed to the console. 30 | - [X] **Task 6:** Add a keyup event listener to an input field that displays the current value in a paragraph. 31 | 32 | ### Activity 4: Form Events 📝 33 | 34 | - [X] **Task 7:** Add a submit event listener to a form that prevents the default submission and logs the form data to the console. 35 | - [X] **Task 8:** Add a change event listener to a select dropdown that displays the selected value in a paragraph. 36 | 37 | ### Activity 5: Event Delegation 📋 38 | 39 | - [X] **Task 9:** Add a click event listener to a list that logs the text content of the clicked list item using event delegation. 40 | - [X] **Task 10:** Add an event listener to a parent element that listens for events from dynamically added child elements. 41 | 42 | ## Feature Requests (Optional) 🌟 43 | 44 | 1. **Click Event Script:** Write a script that adds a click event listener to a button to change the text content of a paragraph. 45 | 2. **Mouse Events Script:** Create a script that handles mouseover and mouseout events to change the background color of an element. 46 | 3. **Keyboard Events Script:** Write a script that logs key presses and displays input field values using keydown and keyup event listeners. 47 | 4. **Form Events Script:** Create a script that handles form submission and change events on a select dropdown. 48 | 5. **Event Delegation Script:** Write a script that demonstrates event delegation by handling events on dynamically added child elements. 49 | 50 | Happy coding! 💻✨ -------------------------------------------------------------------------------- /Day11/Task.md: -------------------------------------------------------------------------------- 1 | # Day 11: Promises and Async/Await 🚀 2 | 3 | Welcome to Day 11 of our JavaScript workshop! Today, we will dive into handling asynchronous operations using Promises and Async/Await. 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Understanding Promises 8 | 9 | - [X] **Task 1:** Create a promise that resolves with a message after a 2-second timeout and log the message to the console. 10 | - [X] **Task 2:** Create a promise that rejects with an error message after a 2-second timeout and handle the error using `.catch()`. 11 | 12 | ### Activity 2: Chaining Promises 13 | 14 | - [X] **Task 3:** Create a sequence of promises that simulate fetching data from a server. Chain the promises to log messages in a specific order. 15 | 16 | ### Activity 3: Using Async/Await 17 | 18 | - [X] **Task 4:** Write an async function that waits for a promise to resolve and then logs the resolved value. 19 | - [X] **Task 5:** Write an async function that handles a rejected promise using try-catch and logs the error message. 20 | 21 | ### Activity 4: Fetching Data from an API 22 | 23 | - [X] **Task 6:** Use the `fetch` API to get data from a public API and log the response data to the console using promises. 24 | - [X] **Task 7:** Use the `fetch` API to get data from a public API and log the response data to the console using async/await. 25 | 26 | ### Activity 5: Concurrent Promises 27 | 28 | - [X] **Task 8:** Use `Promise.all` to wait for multiple promises to resolve and then log all their values. 29 | - [X] **Task 9:** Use `Promise.race` to log the value of the first promise that resolves among multiple promises. 30 | 31 | ## Feature Request 📋 32 | 33 | 1. **Promise Creation Script:** Write a script that demonstrates creating and handling promises, including both resolved and rejected states. 34 | 2. **Promise Chaining Script:** Create a script that chains multiple promises and logs messages in a specific sequence. 35 | 3. **Async/Await Script:** Write a script that uses async/await to handle promises and includes error handling with try-catch. 36 | 4. **API Fetch Script:** Create a script that fetches data from a public API using both promises and async/await, and logs the response data. 37 | 5. **Concurrent Promises Script:** Write a script that uses `Promise.all` and `Promise.race` to handle multiple promises concurrently and logs the results. 38 | 39 | ## Achievement 🎓 40 | 41 | By the end of these activities, students will: 42 | 43 | - ✅ Understand and create promises, including handling resolved and rejected states. 44 | - ✅ Chain multiple promises to perform sequential asynchronous operations. 45 | - ✅ Use async/await to handle asynchronous code more readably. 46 | - ✅ Fetch data from public APIs using both promises and async/await. 47 | - ✅ Manage multiple concurrent promises using `Promise.all` and `Promise.race`. 48 | 49 | --- 50 | 51 | Happy Coding 🚀 -------------------------------------------------------------------------------- /Day12/Task.md: -------------------------------------------------------------------------------- 1 | # Day 12: Error Handling 🚀 2 | 3 | Welcome to Day 12 of our JavaScript workshop! Today, we will focus on mastering error handling to create robust and resilient code. 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Basic Error Handling with Try-Catch 8 | 9 | - [X] **Task 1:** Write a function that intentionally throws an error and use a try-catch block to handle the error and log an appropriate message to the console. 10 | - [X] **Task 2:** Create a function that divides two numbers and throws an error if the denominator is zero. Use a try-catch block to handle this error. 11 | 12 | ### Activity 2: Finally Block 13 | 14 | - [X] **Task 3:** Write a script that includes a try-catch block and a finally block. Log messages in the try, catch, and finally blocks to observe the execution flow. 15 | 16 | ### Activity 3: Custom Error Objects 17 | 18 | - [X] **Task 4:** Create a custom error class that extends the built-in Error class. Throw an instance of this custom error in a function and handle it using a try-catch block. 19 | - [X] **Task 5:** Write a function that validates user input (e.g., checking if a string is not empty) and throws a custom error if the validation fails. Handle the custom error using a try-catch block. 20 | 21 | ### Activity 4: Error Handling in Promises 22 | 23 | - [X] **Task 6:** Create a promise that randomly resolves or rejects. Use `.catch()` to handle the rejection and log an appropriate message to the console. 24 | - [X] **Task 7:** Use try-catch within an async function to handle errors from a promise that randomly resolves or rejects, and log the error message. 25 | 26 | ### Activity 5: Graceful Error Handling in Fetch 27 | 28 | - [X] **Task 8:** Use the `fetch` API to request data from an invalid URL and handle the error using `.catch()`. Log an appropriate error message to the console. 29 | - [X] **Task 9:** Use the `fetch` API to request data from an invalid URL within an async function and handle the error using try-catch. Log an appropriate error message. 30 | 31 | ## Feature Request 📋 32 | 33 | 1. **Basic Error Handling Script:** Write a script that demonstrates basic error handling using try-catch and finally blocks. 34 | 2. **Custom Error Script:** Create a script that defines and throws custom errors, handling them with try-catch blocks. 35 | 3. **Promise Error Handling Script:** Write a script that handles errors in promises using `.catch()` and try-catch within async functions. 36 | 4. **Fetch Error Handling Script:** Create a script that handles errors when using the `fetch` API to request data from invalid URLs. 37 | 38 | ## Achievement 🎓 39 | 40 | By the end of these activities, students will: 41 | 42 | - ✅ Understand and implement basic error handling using try-catch blocks. 43 | - ✅ Use finally blocks to execute code regardless of the try-catch outcome. 44 | - ✅ Create and use custom error classes. 45 | - ✅ Handle errors in promises using `.catch()` and within async functions using try-catch. 46 | - ✅ Implement graceful error handling when making network requests with the `fetch` API. 47 | 48 | --- 49 | 50 | Happy Coding! 🚀 -------------------------------------------------------------------------------- /Day12/index.js: -------------------------------------------------------------------------------- 1 | console.log("-------------------------------------------------"); 2 | console.log("Activity 1: "); 3 | 4 | // Task 1: Write a function that intentionally throws an error and use a try-catch block to handle the error and log an appropriate message to the console. 5 | 6 | function throwError() { 7 | throw new Error("This is an error message"); 8 | } 9 | 10 | try { 11 | throwError(); 12 | } catch (error) { 13 | console.log(error.message); 14 | } 15 | 16 | // Task 2: Create a function that divides two numbers and throws an error if the denominator is zero. Use a try-catch block to handle this error. 17 | 18 | function diverror(){ 19 | try { 20 | let a = 10; 21 | let b = 0; 22 | if (b==0) {throw new Error("Divide by zero error");}; 23 | console.log(c); 24 | } catch (error) { 25 | console.log("Error: " + error.message); 26 | } 27 | } 28 | 29 | diverror(); 30 | 31 | console.log("-------------------------------------------------"); 32 | console.log("Activity 2: "); 33 | 34 | // Task 3: Write a script that includes a try-catch block and a finally block. Log messages in the try, catch, and finally blocks to observe the execution flow. 35 | try{ 36 | console.log("Start of try runs"); 37 | unicycle; 38 | console.log("End of try runs"); 39 | }catch(err){ 40 | console.log("Error has occured: " + err); 41 | }finally{ 42 | console.log("This is always run"); 43 | } 44 | 45 | console.log("-------------------------------------------------"); 46 | console.log("Activity 3: "); 47 | 48 | // Task 4: Create a custom error class that extends the built-in Error class. Throw an instance of this custom error in a function and handle it using a try-catch block. 49 | 50 | class CustomError extends Error { 51 | constructor(message) { 52 | super(message); 53 | this.name = this.constructor.name; 54 | } 55 | } 56 | 57 | function customError() { 58 | throw new CustomError("This is a custom error"); 59 | } 60 | 61 | try { 62 | customError(); 63 | } catch (error) { 64 | console.log(error.message); 65 | } 66 | 67 | // Task 5: Write a function that validates user input (e.g., checking if a string is not empty) and throws a custom error if the validation fails. Handle the custom error using a try-catch block. 68 | 69 | class ValidationError extends Error { 70 | constructor(message) { 71 | super(message); 72 | this.name = this.constructor.name; 73 | } 74 | } 75 | 76 | function validateInput(input) { 77 | if (input === "") { 78 | throw new ValidationError("Input cannot be empty"); 79 | } 80 | } 81 | 82 | try { 83 | validateInput(""); 84 | console.log("Validating input..."); 85 | }catch(error){ 86 | console.log(error.message); 87 | } 88 | 89 | console.log("-------------------------------------------------"); 90 | console.log("Activity 4: "); 91 | 92 | // Task 6: Create a promise that randomly resolves or rejects. Use .catch() to handle the rejection and log an appropriate message to the console. 93 | 94 | let promise = new Promise((resolve, reject) => { 95 | let random = Math.random(); 96 | if (random < 0.5) { 97 | resolve("Success"); 98 | } else { 99 | reject("Error"); 100 | } 101 | }); 102 | 103 | promise.then((message) => { 104 | console.log(message); 105 | }).catch((error) => { 106 | console.log(error); 107 | }); 108 | 109 | 110 | // Task 7: Use try-catch within an async function to handle errors from a promise that randomly resolves or rejects, and log the error message. 111 | 112 | let promise2 = new Promise((resolve, reject) => { 113 | let random = Math.random(); 114 | if (random < 0.5) { 115 | resolve("Success"); 116 | } else { 117 | reject("Error"); 118 | } 119 | }); 120 | 121 | promise2.then((message) => { 122 | console.log(message); 123 | }).catch((error) => { 124 | console.log(error); 125 | }); 126 | 127 | async function randomPromise() { 128 | try { 129 | let result = await promise2; 130 | console.log(result); 131 | } catch (error) { 132 | console.log(error); 133 | } 134 | } 135 | 136 | randomPromise(); 137 | 138 | console.log("-------------------------------------------------"); 139 | console.log("Activity 5: "); 140 | 141 | // Task 8: Use the fetch API to request data from an invalid URL and handle the error using .catch(). Log an appropriate error message to the console. 142 | 143 | fetch("https://jsonplaceholder.typicode.") 144 | .then((response) => response.json()) 145 | .then((data) => console.log(data)) 146 | .catch((error) => console.log("Error: " + error)); 147 | 148 | // Task 9: Use the fetch API to request data from an invalid URL within an async function and handle the error using try-catch. Log an appropriate error message. 149 | 150 | async function fetchData() { 151 | try { 152 | let response = await fetch("https://r.typicocom/posts"); 153 | let data = await response.json(); 154 | console.log(data); 155 | } catch (error) { 156 | console.log("Error: " + error); 157 | } 158 | } -------------------------------------------------------------------------------- /Day13/Task.md: -------------------------------------------------------------------------------- 1 | # Day 13: Modules 📦 2 | 3 | Welcome to Day 13 of our JavaScript workshop! Today, we will dive into the world of modules, learning how to create, export, and import them to keep our code organized and maintainable. 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Creating and Exporting Modules 8 | 9 | - [X] **Task 1:** Create a module that exports a function to add two numbers. Import and use this module in another script. 10 | - [X] **Task 2:** Create a module that exports an object representing a person with properties and methods. Import and use this module in another script. 11 | 12 | ### Activity 2: Named and Default Exports 13 | 14 | - [X] **Task 3:** Create a module that exports multiple functions using named exports. Import and use these functions in another script. 15 | - [X] **Task 4:** Create a module that exports a single function using default export. Import and use this function in another script. 16 | 17 | ### Activity 3: Importing Entire Modules 18 | 19 | - [X] **Task 5:** Create a module that exports multiple constants and functions. Import the entire module as an object in another script and use its properties. 20 | 21 | ### Activity 4: Using Third-Party Modules 22 | 23 | - [X] **Task 6:** Install a third-party module (e.g., lodash) using npm. Import and use a function from this module in a script. 24 | - [X] **Task 7:** Install a third-party module (e.g., axios) using npm. Import and use this module to make a network request in a script. 25 | 26 | ### Activity 5: Module Bundling (Optional) 27 | 28 | - [X] **Task 8:** Use a module bundler like Webpack or Parcel to bundle multiple JavaScript files into a single file. Write a script to demonstrate the bundling process. 29 | 30 | ## Feature Request 📋 31 | 32 | 1. **Basic Module Script:** Write a script that creates a module exporting a function and imports it in another script. 33 | 2. **Named and Default Exports Script:** Create a script demonstrating both named and default exports and their usage. 34 | 3. **Third-Party Module Script:** Write a script that installs, imports, and uses functions from third-party modules like lodash and axios. 35 | 4. **Module Bundling Script:** Create a script demonstrating how to bundle JavaScript files using a module bundler (optional). 36 | 37 | ## Achievement 🎓 38 | 39 | By the end of these activities, students will: 40 | 41 | - ✅ Create and export functions, objects, and constants using modules. 42 | - ✅ Import modules using named and default imports. 43 | - ✅ Use third-party modules installed via npm. 44 | - ✅ Understand the basics of module bundling (optional). 45 | 46 | --- 47 | 48 | Let's get started on organizing our code with modules! 🚀 -------------------------------------------------------------------------------- /Day13/index.js: -------------------------------------------------------------------------------- 1 | console.log("-------------------------------------------------"); 2 | console.log("Activity 1: "); 3 | 4 | // Task 1: Create a module that exports a function to add two numbers. Import and use this module in another script. 5 | 6 | 7 | function add(a, b) { 8 | return a + b; 9 | } 10 | 11 | module.exports = add; 12 | 13 | // Task 2: Create a module that exports an object representing a person with properties and methods. Import and use this module in another script. 14 | 15 | const person = { 16 | name: "John", 17 | age: 25, 18 | greet: function() { 19 | return "Hello, I am " + this.name; 20 | } 21 | } 22 | 23 | module.exports = person; 24 | 25 | console.log("-------------------------------------------------"); 26 | console.log("Activity 2: "); 27 | 28 | // Task 3: Create a module that exports multiple functions using named exports. Import and use these functions in another script. 29 | 30 | function multiply(a, b) { 31 | return a * b; 32 | } 33 | 34 | function divide(a, b) { 35 | return a / b; 36 | } 37 | 38 | module.exports = { 39 | multiply, 40 | divide 41 | } 42 | 43 | // Task 4: Create a module that exports a single function using default export. Import and use this function in another script. 44 | 45 | function subtract(a, b) { 46 | return a - b; 47 | } 48 | 49 | module.exports = subtract; 50 | 51 | console.log("-------------------------------------------------"); 52 | console.log("Activity 3: "); 53 | 54 | // Task 5: Create a module that exports multiple constants and functions. Import the entire module as an object in another script and use its properties. 55 | 56 | const PI = 3.14; 57 | const E = 2.71; 58 | 59 | function square(x) { 60 | return x * x; 61 | } 62 | 63 | function cube(x) { 64 | return x * x * x; 65 | } 66 | 67 | module.exports = { 68 | PI, 69 | E, 70 | square, 71 | cube 72 | } 73 | 74 | console.log("-------------------------------------------------"); 75 | console.log("Activity 4: "); 76 | 77 | // Task 6: Install a third-party module (e.g., lodash) using npm. Import and use a function from this module in a script. 78 | 79 | const _ = require('lodash'); 80 | const arr = [1, 2, 3, 4, 5]; 81 | console.log(_.sum(arr)); 82 | 83 | // Task 7: Install a third-party module (e.g., axios) using npm. Import and use this module to make a network request in a script. 84 | 85 | const axios = require('axios'); 86 | 87 | axios.get('https://jsonplaceholder.typicode.com/posts') 88 | .then(response => { 89 | console.log(response.data); 90 | }) 91 | .catch(error => { 92 | console.log(error); 93 | }); 94 | 95 | console.log("-------------------------------------------------"); 96 | console.log("Activity 5: "); 97 | 98 | // Task 8: Use a module bundler like Webpack or Parcel to bundle multiple JavaScript files into a single file. Write a script to demonstrate the bundling process. 99 | 100 | 101 | // Webpack is used to bundle multiple JavaScript files into a single file. 102 | 103 | // Step 1: Install Webpack 104 | // npm install webpack webpack-cli --save-dev 105 | 106 | // Step 2: Create a webpack.config.js file 107 | 108 | // webpack.config.js 109 | 110 | module.exports = { 111 | entry: './src/index.js', 112 | output: { 113 | filename: 'bundle.js' 114 | } 115 | }; 116 | 117 | 118 | // Step 3: Create multiple JavaScript files to bundle 119 | 120 | // src/index.js 121 | 122 | import { add } from './add.js'; 123 | const add = require('./add'); 124 | 125 | console.log(add(2, 3)); 126 | 127 | // src/add.js 128 | 129 | export function add(a, b) { 130 | return a + b; 131 | } 132 | 133 | // Step 4: Run Webpack to bundle the files 134 | 135 | // npx webpack 136 | 137 | // Step 5: Run the bundled file 138 | 139 | // node dist/bundle.js 140 | 141 | // The output will be 5. 142 | 143 | console.log("-------------------------------------------------"); -------------------------------------------------------------------------------- /Day14/Task.md: -------------------------------------------------------------------------------- 1 | # Day 14: Classes 🏫 2 | 3 | Welcome to Day 14 of our JavaScript workshop! Today, we will explore classes, a fundamental feature of object-oriented programming in JavaScript. Let's get started! 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Class Definition 8 | 9 | - [ ] **Task 1:** Define a class `Person` with properties `name` and `age`, and a method to return a greeting message. Create an instance of the class and log the greeting message. 10 | - [ ] **Task 2:** Add a method to the `Person` class that updates the `age` property and logs the updated age. 11 | 12 | ### Activity 2: Class Inheritance 13 | 14 | - [ ] **Task 3:** Define a class `Student` that extends the `Person` class. Add a property `studentId` and a method to return the student ID. Create an instance of the `Student` class and log the student ID. 15 | - [ ] **Task 4:** Override the greeting method in the `Student` class to include the student ID in the message. Log the overridden greeting message. 16 | 17 | ### Activity 3: Static Methods and Properties 18 | 19 | - [ ] **Task 5:** Add a static method to the `Person` class that returns a generic greeting message. Call this static method without creating an instance of the class and log the message. 20 | - [ ] **Task 6:** Add a static property to the `Student` class to keep track of the number of students created. Increment this property in the constructor and log the total number of students. 21 | 22 | ### Activity 4: Getters and Setters 23 | 24 | - [ ] **Task 7:** Add a getter method to the `Person` class to return the full name (assume a `firstName` and `lastName` property). Create an instance and log the full name using the getter. 25 | - [ ] **Task 8:** Add a setter method to the `Person` class to update the name properties (`firstName` and `lastName`). Update the name using the setter and log the updated full name. 26 | 27 | ### Activity 5: Private Fields (Optional) 28 | 29 | - [ ] **Task 9:** Define a class `Account` with private fields for balance and a method to deposit and withdraw money. Ensure that the balance can only be updated through these methods. 30 | - [ ] **Task 10:** Create an instance of the `Account` class and test the deposit and withdraw methods, logging the balance after each operation. 31 | 32 | ## Feature Request 📋 33 | 34 | 1. **Basic Class Script:** Write a script that defines a `Person` class with properties and methods, creates instances, and logs messages. 35 | 2. **Class Inheritance Script:** Create a script that defines a `Student` class extending `Person`, overrides methods, and logs the results. 36 | 3. **Static Methods and Properties Script:** Write a script that demonstrates static methods and properties in classes. 37 | 4. **Getters and Setters Script:** Create a script that uses getters and setters in a class. 38 | 5. **Private Fields Script:** Write a script that defines a class with private fields and methods to manipulate these fields (optional). 39 | 40 | ## Achievement 🎓 41 | 42 | By the end of these activities, students will: 43 | 44 | - ✅ Define and use classes with properties and methods. 45 | - ✅ Implement inheritance to extend classes. 46 | - ✅ Utilize static methods and properties. 47 | - ✅ Apply getters and setters for encapsulation. 48 | - ✅ Understand and use private fields in classes (optional). 49 | 50 | --- 51 | 52 | Happy Coding 🚀 -------------------------------------------------------------------------------- /Day15/Task.md: -------------------------------------------------------------------------------- 1 | # Day 15: Closures 🔒 2 | 3 | Welcome to Day 15 of our JavaScript workshop! Today, we will dive into closures, an essential concept for creating powerful and encapsulated code. Let's get started! 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Understanding Closures 8 | 9 | - [ ] **Task 1:** Write a function that returns another function, where the inner function accesses a variable from the outer function's scope. Call the inner function and log the result. 10 | - [ ] **Task 2:** Create a closure that maintains a private counter. Implement functions to increment and get the current value of the counter. 11 | 12 | ### Activity 2: Practical Closures 13 | 14 | - [ ] **Task 3:** Write a function that generates unique IDs. Use a closure to keep track of the last generated ID and increment it with each call. 15 | - [ ] **Task 4:** Create a closure that captures a user's name and returns a function that greets the user by name. 16 | 17 | ### Activity 3: Closures in Loops 18 | 19 | - [ ] **Task 5:** Write a loop that creates an array of functions. Each function should log its index when called. Use a closure to ensure each function logs the correct index. 20 | 21 | ### Activity 4: Module Pattern 22 | 23 | - [ ] **Task 6:** Use closures to create a simple module for managing a collection of items. Implement methods to add, remove, and list items. 24 | 25 | ### Activity 5: Memoization 26 | 27 | - [ ] **Task 7:** Write a function that memoizes the results of another function. Use a closure to store the results of previous computations. 28 | - [ ] **Task 8:** Create a memoized version of a function that calculates the factorial of a number. 29 | 30 | ## Feature Request 📋 31 | 32 | 1. **Basic Closure Script:** Write a script that demonstrates a basic closure with a function returning another function that accesses the outer function's variable. 33 | 2. **Counter Closure Script:** Create a script that uses a closure to maintain a private counter with increment and get functions. 34 | 3. **Unique ID Generator Script:** Write a script that generates unique IDs using a closure to keep track of the last generated ID. 35 | 4. **Loop Closure Script:** Create a script that demonstrates closures in loops to ensure functions log the correct index. 36 | 5. **Memoization Script:** Write a script that memoizes the results of a function and demonstrates it with a factorial calculation. 37 | 38 | ## Achievement 🎓 39 | 40 | By the end of these activities, students will: 41 | 42 | - ✅ Understand and create closures in JavaScript. 43 | - ✅ Use closures to maintain private state and create encapsulated modules. 44 | - ✅ Apply closures in practical scenarios like generating unique IDs and memoization. 45 | - ✅ Use closures in loops to capture and use variables correctly. 46 | 47 | --- 48 | 49 | Happy Coding🚀 -------------------------------------------------------------------------------- /Day15/index.js: -------------------------------------------------------------------------------- 1 | console.log("-------------------------------------------------"); 2 | console.log("Activity 1: "); 3 | 4 | // Task 1: Write a function that returns another function, where the inner function accesses a variable from the outer function's scope. Call the inner function and log the result. 5 | 6 | function outerFunction(){ 7 | let message = "Hello, World!"; 8 | function innerFunction(){ 9 | console.log(message); 10 | } 11 | return innerFunction; 12 | } 13 | 14 | const innerFunction = outerFunction(); 15 | innerFunction(); 16 | 17 | // Task 2: Create a closure that maintains a private counter. Implement functions to increment and get the current value of the counter. 18 | 19 | function counter(){ 20 | let count = 0; 21 | return { 22 | increment: function(){ 23 | count++; 24 | }, 25 | getCount: function(){ 26 | return count; 27 | } 28 | }; 29 | } 30 | 31 | const counter1 = counter(); 32 | counter1.increment(); 33 | counter1.increment(); 34 | console.log(counter1.getCount()); 35 | 36 | 37 | console.log("-------------------------------------------------"); 38 | console.log("Activity 2: "); 39 | 40 | // Task 3: Write a function that generates unique IDs. Use a closure to keep track of the last generated ID and increment it with each call. 41 | 42 | function generateID(){ 43 | let id = 0; 44 | return function(){ 45 | id++; 46 | return id; 47 | }; 48 | } 49 | 50 | const idGenerator = generateID(); 51 | console.log(idGenerator()); 52 | 53 | // Task 4: Create a closure that captures a user's name and returns a function that greets the user by name. 54 | 55 | function greetUser(name){ 56 | return function(){ 57 | console.log(`Hello, ${name}!`); 58 | }; 59 | } 60 | 61 | const greet = greetUser("John"); 62 | greet(); 63 | 64 | 65 | console.log("-------------------------------------------------"); 66 | console.log("Activity 3: "); 67 | 68 | 69 | // Task 5: Write a loop that creates an array of functions. Each function should log its index when called. Use a closure to ensure each function logs the correct index. 70 | 71 | function createFunctions(n){ 72 | const functions = []; 73 | for(let i = 0; i < n; i++){ 74 | functions.push(function(){ 75 | console.log(i); 76 | }); 77 | } 78 | return functions; 79 | } 80 | 81 | const functions = createFunctions(3); 82 | functions.forEach(func => func()); 83 | 84 | 85 | console.log("-------------------------------------------------"); 86 | console.log("Activity 4: "); 87 | 88 | // Task 6: Use closures to create a simple module for managing a collection of items. Implement methods to add, remove, and list items. 89 | 90 | function createModule(){ 91 | const items = []; 92 | return { 93 | add: function(item){ 94 | items.push(item); 95 | }, 96 | remove: function(index){ 97 | items.splice(index, 1); 98 | }, 99 | list: function(){ 100 | return items; 101 | } 102 | }; 103 | } 104 | 105 | // const module = createModule(); 106 | // module.add("Apple"); 107 | // module.add("Banana"); 108 | // module.add("Cherry"); 109 | // console.log(module.list()); 110 | // module.remove 111 | // module.remove 112 | // module.remove 113 | // console.log(module.list()); 114 | console.log("Completed Actviity-4"); 115 | 116 | 117 | console.log("-------------------------------------------------"); 118 | console.log("Activity 5: "); 119 | 120 | // Task 7: Write a function that memoizes the results of another function. Use a closure to store the results of previous computations. 121 | 122 | function memoize(func){ 123 | const cache = {}; 124 | return function(n){ 125 | if(cache[n] === undefined){ 126 | cache[n] = func(n); 127 | } 128 | return cache[n]; 129 | }; 130 | } 131 | 132 | function factorial(n){ 133 | if(n === 0){ 134 | return 1; 135 | } 136 | return n * factorial(n - 1); 137 | } 138 | 139 | const memoizedFactorial = memoize(factorial); 140 | console.log(memoizedFactorial(5)); 141 | 142 | // Task 8: Create a memoized version of a function that calculates the factorial of a number. 143 | 144 | function memoizeFactorial(n){ 145 | if(n === 0){ 146 | return 1; 147 | } 148 | return n * memoizeFactorial(n - 1); 149 | } 150 | 151 | const memoizedFactorial1 = memoize(memoizeFactorial); 152 | console.log(memoizedFactorial1(5)); 153 | 154 | -------------------------------------------------------------------------------- /Day16/Task.md: -------------------------------------------------------------------------------- 1 | # Day 16: Recursion 🔁 2 | 3 | Welcome to Day 16 of our JavaScript workshop! Today, we'll explore the power of recursion. Recursion is a technique where a function calls itself to solve a problem. Let's dive into these tasks and master recursion! 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Basic Recursion 8 | 9 | - [X] **Task 1:** Write a recursive function to calculate the factorial of a number. Log the result for a few test cases. 10 | - [X] **Task 2:** Write a recursive function to calculate the nth Fibonacci number. Log the result for a few test cases. 11 | 12 | ### Activity 2: Recursion with Arrays 13 | 14 | - [X] **Task 3:** Write a recursive function to find the sum of all elements in an array. Log the result for a few test cases. 15 | - [X] **Task 4:** Write a recursive function to find the maximum element in an array. Log the result for a few test cases. 16 | 17 | ### Activity 3: String Manipulation with Recursion 18 | 19 | - [X] **Task 5:** Write a recursive function to reverse a string. Log the result for a few test cases. 20 | - [X] **Task 6:** Write a recursive function to check if a string is a palindrome. Log the result for a few test cases. 21 | 22 | ### Activity 4: Recursive Search 23 | 24 | - [X] **Task 7:** Write a recursive function to perform a binary search on a sorted array. Log the index of the target element for a few test cases. 25 | - [X] **Task 8:** Write a recursive function to count the occurrences of a target element in an array. Log the result for a few test cases. 26 | 27 | ### Activity 5: Tree Traversal (Optional) 28 | 29 | - [X] **Task 9:** Write a recursive function to perform an in-order traversal of a binary tree. Log the nodes as they are visited. 30 | - [X] **Task 10:** Write a recursive function to calculate the depth of a binary tree. Log the result for a few test cases. 31 | 32 | ## Feature Request 📋 33 | 34 | 1. **Factorial and Fibonacci Script:** Write a script that includes recursive functions to calculate the factorial and Fibonacci numbers. 35 | 2. **Array Recursion Script:** Create a script that includes recursive functions to find the sum and maximum element of an array. 36 | 3. **String Recursion Script:** Write a script that includes recursive functions to reverse a string and check if a string is a palindrome. 37 | 4. **Recursive Search Script:** Create a script that includes recursive functions for binary search and counting occurrences in an array. 38 | 5. **Tree Traversal Script:** Write a script that includes recursive functions for in-order traversal and depth calculation of a binary tree (optional). 39 | 40 | ## Achievement 🎓 41 | 42 | By the end of these activities, students will: 43 | 44 | - ✅ Understand and implement basic recursion. 45 | - ✅ Apply recursion to solve problems with arrays and strings. 46 | - ✅ Use recursion for searching and counting elements in arrays. 47 | - ✅ Perform tree traversal and calculate tree depth using recursion (optional). 48 | 49 | --- 50 | 51 | Happy Coding ! 🚀 -------------------------------------------------------------------------------- /Day16/index.js: -------------------------------------------------------------------------------- 1 | console.log("-------------------------------------------------"); 2 | console.log("Activity 1: "); 3 | 4 | // Task 1: Write a recursive function to calculate the factorial of a number. Log the result for a few test cases. 5 | 6 | function factorial(n) { 7 | if (n === 0) return 1; 8 | return n * factorial(n - 1); 9 | } 10 | 11 | console.log(factorial(5)); // 120 12 | 13 | // Task 2: Write a recursive function to calculate the nth Fibonacci number. Log the result for a few test cases. 14 | 15 | function fibonacci(n) { 16 | if (n <= 1) return n; 17 | return fibonacci(n - 1) + fibonacci(n - 2); 18 | } 19 | 20 | console.log(fibonacci(10)); // 55 21 | 22 | console.log("-------------------------------------------------"); 23 | console.log("Activity 2: "); 24 | 25 | // Task 3: Write a recursive function to find the sum of all elements in an array. Log the result for a few test cases. 26 | 27 | function sumOfArray(arr, n) { 28 | if (n <= 0) return 0; 29 | return sumOfArray(arr, n - 1) + arr[n - 1]; 30 | } 31 | 32 | console.log(sumOfArray([1, 2, 3, 4, 5], 5)); // 15 33 | 34 | // Task 4: Write a recursive function to find the maximum element in an array. Log the result for a few test cases. 35 | 36 | function maxOfArray(arr, n) { 37 | if (n === 1) return arr[0]; 38 | return Math.max(arr[n - 1], maxOfArray(arr, n - 1)); 39 | } 40 | 41 | console.log(maxOfArray([19, 22, 43, 84, 125], 5)); // 125 42 | 43 | console.log("-------------------------------------------------"); 44 | console.log("Activity 3: "); 45 | 46 | // Task 5: Write a recursive function to reverse a string. Log the result for a few test cases. 47 | 48 | function reverseString(str) { 49 | if (str === "") return ""; 50 | return reverseString(str.substr(1)) + str.charAt(0); 51 | } 52 | 53 | console.log(reverseString("hello")); // olleh 54 | 55 | // Task 6: Write a recursive function to check if a string is a palindrome. Log the result for a few test cases. 56 | 57 | function isPalindrome(str) { 58 | if (str.length <= 1) return true; 59 | if (str[0] !== str[str.length - 1]) return false; 60 | return isPalindrome(str.substr(1, str.length - 2)); 61 | } 62 | 63 | console.log(isPalindrome("Dad")); // true 64 | 65 | console.log("-------------------------------------------------"); 66 | console.log("Activity 4: "); 67 | 68 | // Task 7: Write a recursive function to perform a binary search on a sorted array. Log the index of the target element for a few test cases. 69 | 70 | function binarySearch(arr, target, start, end) { 71 | if (start > end) return -1; 72 | let mid = Math.floor((start + end) / 2); 73 | if (arr[mid] === target) return mid; 74 | if (arr[mid] > target) return binarySearch(arr, target, start, mid - 1); 75 | return binarySearch(arr, target, mid + 1, end); 76 | } 77 | 78 | let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]; 79 | console.log(binarySearch(arr, 5, 0, arr.length - 1)); // 4 80 | 81 | // Task 8: Write a recursive function to count the occurrences of a target element in an array. Log the result for a few test cases. 82 | 83 | function countOccurrences(arr, target, n) { 84 | if (n < 0) return 0; 85 | return (arr[n] === target ? 1 : 0) + countOccurrences(arr, target, n - 1); 86 | } 87 | 88 | console.log(countOccurrences([1, 2, 3, 4, 5, 4, 3, 2, 1], 3, 8)); // 2 89 | 90 | 91 | console.log("-------------------------------------------------"); 92 | console.log("Activity 5: "); 93 | 94 | // Task 9: Write a recursive function to perform an in-order traversal of a binary tree. Log the nodes as they are visited. 95 | 96 | class Node { 97 | constructor(data) { 98 | this.data = data; 99 | this.left = null; 100 | this.right = null; 101 | } 102 | } 103 | 104 | function inOrderTraversal(node) { 105 | if (node !== null) { 106 | inOrderTraversal(node.left); 107 | console.log(node.data); 108 | inOrderTraversal(node.right); 109 | } 110 | } 111 | 112 | let root = new Node(1); 113 | root.left = new Node(2); 114 | root.right = new Node(3); 115 | root.left.left = new Node(4); 116 | root.left.right = new Node(5); 117 | 118 | inOrderTraversal(root); // 4 2 5 1 3 119 | 120 | // Task 10: Write a recursive function to calculate the depth of a binary tree. Log the result for a few test cases. 121 | 122 | function maxDepth(node) { 123 | if (node === null) return 0; 124 | let leftDepth = maxDepth(node.left); 125 | let rightDepth = maxDepth(node.right); 126 | return Math.max(leftDepth, rightDepth) + 1; 127 | } 128 | 129 | console.log(maxDepth(root)); // 3 130 | 131 | console.log("-------------------------------------------------"); -------------------------------------------------------------------------------- /Day17/Task.md: -------------------------------------------------------------------------------- 1 | # Day 17: Data Structures 📊 2 | 3 | Welcome to Day 17 of our JavaScript journey! Today, we're diving into essential data structures like Linked Lists, Stacks, Queues, Binary Trees, and even Graphs. Understanding these will help you manage and organize data more effectively in your applications. Let's get started! 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Linked List 8 | 9 | - [X] **Task 1:** Implement a `Node` class to represent an element in a linked list with properties `value` and `next`. 10 | - [X] **Task 2:** Implement a `LinkedList` class with methods to add a node to the end, remove a node from the end, and display all nodes. 11 | 12 | ### Activity 2: Stack 13 | 14 | - [X] **Task 3:** Implement a `Stack` class with methods `push` (add element), `pop` (remove element), and `peek` (view the top element). 15 | - [X] **Task 4:** Use the `Stack` class to reverse a string by pushing all characters onto the stack and then popping them off. 16 | 17 | ### Activity 3: Queue 18 | 19 | - [X] **Task 5:** Implement a `Queue` class with methods `enqueue` (add element), `dequeue` (remove element), and `front` (view the first element). 20 | - [X] **Task 6:** Use the `Queue` class to simulate a simple printer queue where print jobs are added to the queue and processed in order. 21 | 22 | ### Activity 4: Binary Tree 23 | 24 | - [X] **Task 7:** Implement a `TreeNode` class to represent a node in a binary tree with properties `value`, `left`, and `right`. 25 | - [X] **Task 8:** Implement a `BinaryTree` class with methods for inserting values and performing in-order traversal to display nodes. 26 | 27 | ### Activity 5: Graph (Optional) 28 | 29 | - [X] **Task 9:** Implement a `Graph` class with methods to add vertices, add edges, and perform a breadth-first search (BFS). 30 | - [X] **Task 10:** Use the `Graph` class to represent a simple network and perform BFS to find the shortest path between two nodes. 31 | 32 | ## Feature Request 📋 33 | 34 | 1. **Linked List Script:** Write a script that implements a linked list with methods to add, remove, and display nodes. 35 | 2. **Stack Script:** Create a script that implements a stack and uses it to reverse a string. 36 | 3. **Queue Script:** Write a script that implements a queue and simulates a printer queue. 37 | 4. **Binary Tree Script:** Create a script that implements a binary tree with insertion and in-order traversal methods. 38 | 5. **Graph Script:** Write a script that implements a graph and performs breadth-first search (optional). 39 | 40 | ## Achievement 🎓 41 | 42 | By the end of these activities, students will: 43 | 44 | - ✅ Implement and use linked lists for dynamic data storage. 45 | - ✅ Use stacks for LIFO (Last-In-First-Out) operations and reverse data. 46 | - ✅ Use queues for FIFO (First-In-First-Out) operations and simulate real-world scenarios. 47 | - ✅ Implement binary trees for hierarchical data storage and traversal. 48 | - ✅ Understand and use graphs for network representations and pathfinding (optional). 49 | 50 | --- 51 | 52 | Happy Coding! 🚀 -------------------------------------------------------------------------------- /Day18/Task.md: -------------------------------------------------------------------------------- 1 | # Day 18: Algorithms 🚀 2 | 3 | Welcome to Day 18 of our coding adventure! Today, we're diving deep into algorithms, the heart of computer science. Understanding these fundamental algorithms will significantly enhance your problem-solving skills. Let's sort, search, and optimize our way through the day! 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Sorting Algorithms 8 | 9 | - [X] **Task 1:** Implement the **bubble sort** algorithm to sort an array of numbers in ascending order. Log the sorted array. 10 | - [X] **Task 2:** Implement the **selection sort** algorithm to sort an array of numbers in ascending order. Log the sorted array. 11 | - [X] **Task 3:** Implement the **quicksort** algorithm to sort an array of numbers in ascending order. Log the sorted array. 12 | 13 | ### Activity 2: Searching Algorithms 14 | 15 | - [X] **Task 4:** Implement the **linear search** algorithm to find a target value in an array. Log the index of the target value. 16 | - [X] **Task 5:** Implement the **binary search** algorithm to find a target value in a sorted array. Log the index of the target value. 17 | 18 | ### Activity 3: String Algorithms 19 | 20 | - [X] **Task 6:** Write a function to **count the occurrences** of each character in a string. Log the character counts. 21 | - [X] **Task 7:** Write a function to find the **longest substring without repeating characters** in a string. Log the length of the substring. 22 | 23 | ### Activity 4: Array Algorithms 24 | 25 | - [X] **Task 8:** Write a function to **rotate an array** by k positions. Log the rotated array. 26 | - [X] **Task 9:** Write a function to **merge two sorted arrays** into one sorted array. Log the merged array. 27 | 28 | ### Activity 5: Dynamic Programming (Optional) 29 | 30 | - [X] **Task 10:** Write a function to solve the **Fibonacci sequence** using dynamic programming. Log the Fibonacci numbers. 31 | - [X] **Task 11:** Write a function to solve the **knapsack problem** using dynamic programming. Log the maximum value that can be obtained. 32 | 33 | ## Feature Request 🎯 34 | 35 | 1. **Sorting Algorithm Script:** Write a script that implements **bubble sort**, **selection sort**, and **quicksort** algorithms to sort arrays. 36 | 2. **Searching Algorithm Script:** Create a script that implements **linear search** and **binary search** algorithms to find values in arrays. 37 | 3. **String Algorithm Script:** Write a script that **counts character occurrences** and **finds the longest substring** without repeating characters. 38 | 4. **Array Algorithm Script:** Create a script that **rotates arrays** and **merges sorted arrays**. 39 | 5. **Dynamic Programming Script:** Write a script that solves the **Fibonacci sequence** and **knapsack problem** using dynamic programming (optional). 40 | 41 | ## Achievement 🏆 42 | 43 | By the end of these activities, students will: 44 | 45 | - ✅ Implement and understand **common sorting algorithms**. 46 | - ✅ Implement and understand **common searching algorithms**. 47 | - ✅ Solve **string manipulation problems** using algorithms. 48 | - ✅ Perform **array operations** using algorithms. 49 | - ✅ Apply **dynamic programming** to solve complex problems (optional). 50 | 51 | --- 52 | 53 | Time to master algorithms and boost your coding prowess! 💪 -------------------------------------------------------------------------------- /Day19/Task.md: -------------------------------------------------------------------------------- 1 | # Day 19: Regular Expressions 🔍 2 | 3 | Welcome to Day 19! Today, we're diving into the world of Regular Expressions (RegEx) – a powerful tool for pattern matching and string manipulation. With RegEx, you can search, extract, and validate strings with precision. Let’s get started! 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Basic Regular Expressions 8 | 9 | - [X] **Task 1:** Write a regular expression to match a simple pattern (e.g., match all occurrences of the word "JavaScript" in a string). Log the matches. 10 | - [X] **Task 2:** Write a regular expression to match all digits in a string. Log the matches. 11 | 12 | ### Activity 2: Character Classes and Quantifiers 13 | 14 | - [X] **Task 3:** Write a regular expression to match all words in a string that start with a capital letter. Log the matches. 15 | - [X] **Task 4:** Write a regular expression to match all sequences of one or more digits in a string. Log the matches. 16 | 17 | ### Activity 3: Grouping and Capturing 18 | 19 | - [X] **Task 5:** Write a regular expression to capture the area code, central office code, and line number from a US phone number format (e.g., (123) 456-7890). Log the captures. 20 | - [X] **Task 6:** Write a regular expression to capture the username and domain from an email address. Log the captures. 21 | 22 | ### Activity 4: Assertions and Boundaries 23 | 24 | - [X] **Task 7:** Write a regular expression to match a word only if it is at the beginning of a string. Log the matches. 25 | - [X] **Task 8:** Write a regular expression to match a word only if it is at the end of a string. Log the matches. 26 | 27 | ### Activity 5: Practical Applications 28 | 29 | - [X] **Task 9:** Write a regular expression to validate a simple password (must include at least one uppercase letter, one lowercase letter, one digit, and one special character). Log whether the password is valid. 30 | - [X] **Task 10:** Write a regular expression to validate a URL. Log whether the URL is valid. 31 | 32 | ## Feature Request 🎯 33 | 34 | 1. **Basic Regex Script:** Write a script that uses regular expressions to match simple patterns and log the matches. 35 | 2. **Character Classes and Quantifiers Script:** Create a script that uses regular expressions to match words with specific characteristics and log the matches. 36 | 3. **Grouping and Capturing Script:** Write a script that uses regular expressions to capture parts of a string, such as phone numbers and email addresses, and log the captures. 37 | 4. **Assertions and Boundaries Script:** Create a script that uses regular expressions to match words at specific positions in a string and log the matches. 38 | 5. **Validation Script:** Write a script that uses regular expressions to validate passwords and URLs and log whether they are valid. 39 | 40 | ## Achievement 🏆 41 | 42 | By the end of these activities, students will: 43 | 44 | - ✅ Understand and create **basic regular expressions**. 45 | - ✅ Use **character classes and quantifiers** in regular expressions. 46 | - ✅ Implement **grouping and capturing** in regular expressions. 47 | - ✅ Apply **assertions and boundaries** in regular expressions. 48 | - ✅ Use regular expressions for **practical applications** like validating passwords and URLs. 49 | 50 | --- 51 | 52 | Happy Coding! 🎯 -------------------------------------------------------------------------------- /Day19/index.js: -------------------------------------------------------------------------------- 1 | console.log("-------------------------------------------------"); 2 | console.log("Activity 1: "); 3 | 4 | // Task 1: Write a regular expression to match a simple pattern (e.g., match all occurrences of the word "JavaScript" in a string). Log the matches. 5 | 6 | let pattern = /JavaScript/g; 7 | let str = "JavaScript is a scripting language. JavaScript is used for web development. JavaScript makes web pages interactive."; 8 | let matches = str.match(pattern); 9 | 10 | console.log(matches); 11 | 12 | // Task 2: Write a regular expression to match all digits in a string. Log the matches. 13 | 14 | pattern = /\d/g; 15 | str = "There are 12 months in a year."; 16 | matches = str.match(pattern); 17 | 18 | console.log(matches); 19 | 20 | 21 | console.log("-------------------------------------------------"); 22 | console.log("Activity 2: "); 23 | 24 | // Task 3: Write a regular expression to match all words in a string that start with a capital letter. Log the matches. 25 | 26 | pattern = /[A-Z][a-z]+/g; 27 | str = "The quick brown fox Jumps over the lazy dog."; 28 | matches = str.match(pattern); 29 | 30 | console.log(matches); 31 | 32 | // Task 4: Write a regular expression to match all sequences of one or more digits in a string. Log the matches. 33 | 34 | pattern = /\d+/g; 35 | str = "There are 12 months in a year."; 36 | matches = str.match(pattern); 37 | 38 | console.log(matches); 39 | 40 | 41 | console.log("-------------------------------------------------"); 42 | console.log("Activity 3: "); 43 | 44 | // Task 5: Write a regular expression to capture the area code, central office code, and line number from a US phone number format (e.g., (123) 456-7890). Log the captures. 45 | 46 | pattern = /\((\d{3})\)\s(\d{3})-(\d{4})/; 47 | str = "(123) 456-7890"; 48 | matches = str.match(pattern); 49 | 50 | console.log(matches); 51 | 52 | // Task 6: Write a regular expression to capture the username and domain from an email address. Log the captures. 53 | 54 | pattern = /(\w+)@(\w+\.\w+)/; 55 | str = "yashsaini" + "@" + "gmail.com"; 56 | let email = "yashkumarsaini0123456789@gmail.com"; 57 | matches = email.match(pattern); 58 | 59 | console.log(matches); 60 | 61 | 62 | console.log("-------------------------------------------------"); 63 | console.log("Activity 4: "); 64 | 65 | // Task 7: Write a regular expression to match a word only if it is at the beginning of a string. Log the matches. 66 | 67 | pattern = /\b\w+/g; 68 | str = "Hello, World!"; 69 | matches = str.match(pattern); 70 | 71 | console.log(matches); 72 | 73 | // Task 8: Write a regular expression to match a word only if it is at the end of a string. Log the matches. 74 | 75 | pattern = /\w+\b/g; 76 | str = "The quick brown fox jumps over the lazy dog."; 77 | matches = str.match(pattern); 78 | 79 | console.log(matches); 80 | 81 | 82 | console.log("-------------------------------------------------"); 83 | console.log("Activity 5: "); 84 | 85 | // Task 9: Write a regular expression to validate a simple password (must include at least one uppercase letter, one lowercase letter, one digit, and one special character). Log whether the password is valid. 86 | 87 | pattern = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/; 88 | let password = "Password@123"; 89 | let isValid = pattern.test(password); 90 | 91 | console.log(isValid); 92 | 93 | // Task 10: Write a regular expression to validate a URL. Log whether the URL is valid. 94 | 95 | pattern = /^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+)\.([a-zA-Z]{2,})(\/[a-zA-Z0-9-]+)*\/?$/; 96 | let url = "https://www.google.com"; 97 | isValid = pattern.test(url); 98 | 99 | console.log(isValid); 100 | 101 | console.log("-------------------------------------------------"); -------------------------------------------------------------------------------- /Day20/Activity-2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Save User Input 7 | 82 | 83 | 84 |

User Information Form

85 |
86 | 87 | 88 | 89 | 90 | 91 |
92 | 93 |

Saved User Data

94 |
95 |
96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /Day20/Activity-2/script.js: -------------------------------------------------------------------------------- 1 | // Task 3: Create a simple form that saves user input (e.g., name and email) to localStorage when submitted. Retrieve and display the saved data on page load. 2 | 3 | document.addEventListener('DOMContentLoaded', () => { 4 | function displaySavedData() { 5 | const savedData = JSON.parse(localStorage.getItem('userData')); 6 | const savedDataDiv = document.getElementById('savedData'); 7 | if (savedData) { 8 | savedDataDiv.innerHTML = `

Name: ${savedData.name}

Email: ${savedData.email}

`; 9 | } else { 10 | savedDataDiv.innerHTML = '

No data saved.

'; 11 | } 12 | } 13 | 14 | displaySavedData(); 15 | 16 | document.getElementById('userForm').addEventListener('submit', (event) => { 17 | event.preventDefault(); 18 | 19 | const name = document.getElementById('name').value; 20 | const email = document.getElementById('email').value; 21 | 22 | const userData = { name, email }; 23 | localStorage.setItem('userData', JSON.stringify(userData)); 24 | 25 | displaySavedData(); 26 | }); 27 | 28 | // Task 4: Write a script to remove an item from localStorage. Log the localStorage content before and after removal. 29 | 30 | function removeItemFromLocalStorage(key) { 31 | console.log('Before removal:'); 32 | console.log(localStorage.getItem(key)); 33 | 34 | localStorage.removeItem(key); 35 | 36 | console.log('After removal:'); 37 | console.log(localStorage.getItem(key)); 38 | } 39 | 40 | document.getElementById('removeData').addEventListener('click', () => { 41 | removeItemFromLocalStorage('userData'); 42 | displaySavedData(); // Update the displayed data after removal 43 | }); 44 | }); 45 | 46 | -------------------------------------------------------------------------------- /Day20/Activity-4/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | SessionStorage Example 7 | 84 | 85 | 86 |

User Information Form

87 |
88 | 89 | 90 | 91 | 92 | 93 |
94 | 95 |

Saved User Data

96 |
97 |
98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /Day20/Activity-4/script.js: -------------------------------------------------------------------------------- 1 | // Task 7: Save data to sessionStorage on form submission 2 | document.addEventListener('DOMContentLoaded', () => { 3 | const form = document.getElementById('userForm'); 4 | const savedData = document.getElementById('savedData'); 5 | const deleteButton = document.getElementById('deleteData'); 6 | 7 | // Retrieve and display data on page load 8 | const savedName = sessionStorage.getItem('name'); 9 | const savedEmail = sessionStorage.getItem('email'); 10 | 11 | if (savedName && savedEmail) { 12 | savedData.innerHTML = `

Name: ${savedName}

Email: ${savedEmail}

`; 13 | } else { 14 | savedData.innerHTML = '

No data saved yet.

'; 15 | } 16 | 17 | // Save data to sessionStorage on form submission 18 | form.addEventListener('submit', (event) => { 19 | event.preventDefault(); 20 | const name = form.name.value; 21 | const email = form.email.value; 22 | 23 | sessionStorage.setItem('name', name); 24 | sessionStorage.setItem('email', email); 25 | 26 | savedData.innerHTML = `

Name: ${name}

Email: ${email}

`; 27 | }); 28 | 29 | // Task 8: Delete data from sessionStorage on button click 30 | deleteButton.addEventListener('click', () => { 31 | console.log('Before removal:', JSON.stringify(sessionStorage, null, 2)); 32 | sessionStorage.removeItem('name'); 33 | sessionStorage.removeItem('email'); 34 | console.log('After removal:', JSON.stringify(sessionStorage, null, 2)); 35 | 36 | savedData.innerHTML = '

Data deleted.

'; 37 | }); 38 | }); -------------------------------------------------------------------------------- /Day20/Task.md: -------------------------------------------------------------------------------- 1 | # Day 20: LocalStorage and SessionStorage 📦 2 | 3 | Welcome to Day 20! Today, we're diving into the world of web storage with **LocalStorage** and **SessionStorage**. These tools allow you to store data directly in the user's browser, making it easy to save and retrieve information across sessions or within a single session. Let's explore how to use them effectively! 🌐 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Understanding LocalStorage 📚 8 | 9 | - [X] **Task 1:** Write a script to save a string value to `localStorage` and retrieve it. Log the retrieved value. 10 | - [X] **Task 2:** Write a script to save an object to `localStorage` by converting it to a JSON string. Retrieve and parse the object, then log it. 11 | 12 | ### Activity 2: Using LocalStorage 🛠️ 13 | 14 | - [X] **Task 3:** Create a simple form that saves user input (e.g., name and email) to `localStorage` when submitted. Retrieve and display the saved data on page load. 15 | - [X] **Task 4:** Write a script to remove an item from `localStorage`. Log the `localStorage` content before and after removal. 16 | 17 | ### Activity 3: Understanding SessionStorage 🧠 18 | 19 | - [X] **Task 5:** Write a script to save a string value to `sessionStorage` and retrieve it. Log the retrieved value. 20 | - [X] **Task 6:** Write a script to save an object to `sessionStorage` by converting it to a JSON string. Retrieve and parse the object, then log it. 21 | 22 | ### Activity 4: Using SessionStorage 🔄 23 | 24 | - [X] **Task 7:** Create a simple form that saves user input (e.g., name and email) to `sessionStorage` when submitted. Retrieve and display the saved data on page load. 25 | - [X] **Task 8:** Write a script to remove an item from `sessionStorage`. Log the `sessionStorage` content before and after removal. 26 | 27 | ### Activity 5: Comparing LocalStorage and SessionStorage ⚖️ 28 | 29 | - [X] **Task 9:** Write a function that accepts a key and a value, and saves the value to both `localStorage` and `sessionStorage`. Retrieve and log the values from both storage mechanisms. 30 | - [X] **Task 10:** Write a function that clears all data from both `localStorage` and `sessionStorage`. Verify that both storages are empty. 31 | 32 | ## Feature Request 🎯 33 | 34 | 1. **LocalStorage Script:** Write a script that saves, retrieves, and removes items from `localStorage`, and displays the saved data on page load. 35 | 2. **SessionStorage Script:** Create a script that saves, retrieves, and removes items from `sessionStorage`, and displays the saved data on page load. 36 | 3. **Storage Comparison Script:** Write a script that saves data to both `localStorage` and `sessionStorage`, retrieves the data, and compares the results. 37 | 4. **Clear Storage Script:** Create a script that clears all data from both `localStorage` and `sessionStorage`, and verifies the operation. 38 | 39 | ## Achievement Unlocked 🏆 40 | 41 | By the end of these activities, you will: 42 | 43 | - ✅ Understand how to use **LocalStorage** and **SessionStorage** for persistent and session-specific data storage. 44 | - ✅ Save, retrieve, and remove data from both **LocalStorage** and **SessionStorage**. 45 | - ✅ Implement form data storage using **LocalStorage** and **SessionStorage**. 46 | - ✅ Compare and contrast the use cases for **LocalStorage** and **SessionStorage**. 47 | 48 | --- 49 | 50 | Happy Coding! 🚀 -------------------------------------------------------------------------------- /Day20/index.js: -------------------------------------------------------------------------------- 1 | console.log("-------------------------------------------------"); 2 | console.log("Activity 1: "); 3 | 4 | // Task 1: Write a script to save a string value to localStorage and retrieve it. Log the retrieved value. 5 | 6 | const { LocalStorage } = require('node-localstorage'); 7 | const localStorage = new LocalStorage('./scratch'); 8 | localStorage.setItem('myStringKey', 'Hello, World!'); 9 | const retrievedString = localStorage.getItem('myStringKey'); 10 | console.log(retrievedString); // Output: Hello, World! 11 | 12 | 13 | 14 | // Task 2: Write a script to save an object to localStorage by converting it to a JSON string. Retrieve and parse the object, then log it. 15 | 16 | // Define an object 17 | const myObject = { 18 | name: 'Yash', 19 | age: 24, 20 | profession: 'Software Engineer' 21 | }; 22 | localStorage.setItem('myObjectKey', JSON.stringify(myObject)); 23 | const retrievedObject = JSON.parse(localStorage.getItem('myObjectKey')); 24 | console.log(retrievedObject); 25 | 26 | 27 | console.log("-------------------------------------------------"); 28 | console.log("Activity 2: "); 29 | 30 | // Task 3: Create a simple form that saves user input (e.g., name and email) to localStorage when submitted. Retrieve and display the saved data on page load. 31 | // Task 4: Write a script to remove an item from localStorage. Log the localStorage content before and after removal. 32 | console.log("\nTask Completed!"); 33 | 34 | console.log("-------------------------------------------------"); 35 | console.log("Activity 3: "); 36 | 37 | const sessionStorage = new LocalStorage('./session'); 38 | 39 | // Task 5: Write a script to save a string value to sessionStorage and retrieve it. Log the retrieved value. 40 | const stringValue = "Hello, Node.js!"; 41 | sessionStorage.setItem('greeting', stringValue); 42 | 43 | // Retrieve and log the string value from sessionStorage 44 | const retrievedString2 = sessionStorage.getItem('greeting'); 45 | console.log('Retrieved string from sessionStorage:', retrievedString2); 46 | 47 | // Task 6: Write a script to save an object to sessionStorage by converting it to a JSON string. Retrieve and parse the object, then log it. 48 | 49 | // Task 6: Save an object to sessionStorage by converting it to a JSON string 50 | const userObject = { 51 | name: "Yash K. Saini", 52 | email: "yashkumarsaini101@gmail.com", 53 | age: 20 54 | }; 55 | 56 | // Convert object to JSON string and save to sessionStorage 57 | sessionStorage.setItem('user', JSON.stringify(userObject)); 58 | 59 | // Retrieve and parse the object from sessionStorage 60 | const retrievedObjectJSON = sessionStorage.getItem('user'); 61 | const retrievedObject2 = JSON.parse(retrievedObjectJSON); 62 | 63 | console.log('Retrieved object from sessionStorage:', retrievedObject2); 64 | 65 | console.log("-------------------------------------------------"); 66 | console.log("Activity 4: "); 67 | 68 | // Task 7: Create a simple form that saves user input (e.g., name and email) to sessionStorage when submitted. Retrieve and display the saved data on page load. 69 | // Task 8: Write a script to remove an item from sessionStorage. Log the sessionStorage content before and after removal. 70 | console.log("\nTask Completed!"); 71 | 72 | console.log("-------------------------------------------------"); 73 | console.log("Activity 5: "); 74 | 75 | function saveToStorage(key, value) { 76 | // Save to localStorage 77 | localStorage.setItem(key, value); 78 | // Save to sessionStorage 79 | sessionStorage.setItem(key, value); 80 | 81 | // Retrieve and log the values from both storage mechanisms 82 | const localStorageValue = localStorage.getItem(key); 83 | const sessionStorageValue = sessionStorage.getItem(key); 84 | 85 | console.log(`Value from localStorage: ${localStorageValue}`); 86 | console.log(`Value from sessionStorage: ${sessionStorageValue}`); 87 | } 88 | 89 | // Example usage 90 | saveToStorage('username', 'Yash K. Saini'); 91 | 92 | function clearAllStorage() { 93 | // Clear all data from localStorage 94 | localStorage.clear(); 95 | // Clear all data from sessionStorage 96 | sessionStorage.clear(); 97 | 98 | // Verify that both storages are empty 99 | console.log('localStorage after clear:', JSON.stringify(localStorage, null, 2)); 100 | console.log('sessionStorage after clear:', JSON.stringify(sessionStorage, null, 2)); 101 | } 102 | 103 | // clearAllStorage(); This will clear all the data from both localStorage and sessionStorage 104 | 105 | console.log("-------------------------------------------------"); -------------------------------------------------------------------------------- /Day20/node_modules/.package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Day20", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": { 6 | "node_modules/imurmurhash": { 7 | "version": "0.1.4", 8 | "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", 9 | "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", 10 | "license": "MIT", 11 | "engines": { 12 | "node": ">=0.8.19" 13 | } 14 | }, 15 | "node_modules/node-localstorage": { 16 | "version": "3.0.5", 17 | "resolved": "https://registry.npmjs.org/node-localstorage/-/node-localstorage-3.0.5.tgz", 18 | "integrity": "sha512-GCwtK33iwVXboZWYcqQHu3aRvXEBwmPkAMRBLeaX86ufhqslyUkLGsi4aW3INEfdQYpUB5M9qtYf3eHvAk2VBg==", 19 | "license": "MIT", 20 | "dependencies": { 21 | "write-file-atomic": "^5.0.1" 22 | }, 23 | "engines": { 24 | "node": ">=0.12" 25 | } 26 | }, 27 | "node_modules/signal-exit": { 28 | "version": "4.1.0", 29 | "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", 30 | "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", 31 | "license": "ISC", 32 | "engines": { 33 | "node": ">=14" 34 | }, 35 | "funding": { 36 | "url": "https://github.com/sponsors/isaacs" 37 | } 38 | }, 39 | "node_modules/write-file-atomic": { 40 | "version": "5.0.1", 41 | "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", 42 | "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", 43 | "license": "ISC", 44 | "dependencies": { 45 | "imurmurhash": "^0.1.4", 46 | "signal-exit": "^4.0.1" 47 | }, 48 | "engines": { 49 | "node": "^14.17.0 || ^16.13.0 || >=18.0.0" 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Day20/node_modules/imurmurhash/imurmurhash.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve 3 | * JS Implementation of incremental MurmurHash3 (r150) (as of May 10, 2013) 4 | * 5 | * @author Jens Taylor 6 | * @see http://github.com/homebrewing/brauhaus-diff 7 | * @author Gary Court 8 | * @see http://github.com/garycourt/murmurhash-js 9 | * @author Austin Appleby 10 | * @see http://sites.google.com/site/murmurhash/ 11 | */ 12 | !function(){function t(h,r){var s=this instanceof t?this:e;return s.reset(r),"string"==typeof h&&h.length>0&&s.hash(h),s!==this?s:void 0}var e;t.prototype.hash=function(t){var e,h,r,s,i;switch(i=t.length,this.len+=i,h=this.k1,r=0,this.rem){case 0:h^=i>r?65535&t.charCodeAt(r++):0;case 1:h^=i>r?(65535&t.charCodeAt(r++))<<8:0;case 2:h^=i>r?(65535&t.charCodeAt(r++))<<16:0;case 3:h^=i>r?(255&t.charCodeAt(r))<<24:0,h^=i>r?(65280&t.charCodeAt(r++))>>8:0}if(this.rem=3&i+this.rem,i-=this.rem,i>0){for(e=this.h1;;){if(h=4294967295&11601*h+3432906752*(65535&h),h=h<<15|h>>>17,h=4294967295&13715*h+461832192*(65535&h),e^=h,e=e<<13|e>>>19,e=4294967295&5*e+3864292196,r>=i)break;h=65535&t.charCodeAt(r++)^(65535&t.charCodeAt(r++))<<8^(65535&t.charCodeAt(r++))<<16,s=t.charCodeAt(r++),h^=(255&s)<<24^(65280&s)>>8}switch(h=0,this.rem){case 3:h^=(65535&t.charCodeAt(r+2))<<16;case 2:h^=(65535&t.charCodeAt(r+1))<<8;case 1:h^=65535&t.charCodeAt(r)}this.h1=e}return this.k1=h,this},t.prototype.result=function(){var t,e;return t=this.k1,e=this.h1,t>0&&(t=4294967295&11601*t+3432906752*(65535&t),t=t<<15|t>>>17,t=4294967295&13715*t+461832192*(65535&t),e^=t),e^=this.len,e^=e>>>16,e=4294967295&51819*e+2246770688*(65535&e),e^=e>>>13,e=4294967295&44597*e+3266445312*(65535&e),e^=e>>>16,e>>>0},t.prototype.reset=function(t){return this.h1="number"==typeof t?t:0,this.rem=this.k1=this.len=0,this},e=new t,"undefined"!=typeof module?module.exports=t:this.MurmurHash3=t}(); -------------------------------------------------------------------------------- /Day20/node_modules/imurmurhash/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "imurmurhash", 3 | "version": "0.1.4", 4 | "description": "An incremental implementation of MurmurHash3", 5 | "homepage": "https://github.com/jensyt/imurmurhash-js", 6 | "main": "imurmurhash.js", 7 | "files": [ 8 | "imurmurhash.js", 9 | "imurmurhash.min.js", 10 | "package.json", 11 | "README.md" 12 | ], 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/jensyt/imurmurhash-js" 16 | }, 17 | "bugs": { 18 | "url": "https://github.com/jensyt/imurmurhash-js/issues" 19 | }, 20 | "keywords": [ 21 | "murmur", 22 | "murmurhash", 23 | "murmurhash3", 24 | "hash", 25 | "incremental" 26 | ], 27 | "author": { 28 | "name": "Jens Taylor", 29 | "email": "jensyt@gmail.com", 30 | "url": "https://github.com/homebrewing" 31 | }, 32 | "license": "MIT", 33 | "dependencies": { 34 | }, 35 | "devDependencies": { 36 | }, 37 | "engines": { 38 | "node": ">=0.8.19" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Day20/node_modules/node-localstorage/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributing to node-localstorage 3 | 4 | First off, thanks for taking the time to contribute! ❤️ 5 | 6 | All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. The community looks forward to your contributions. 🎉 7 | 8 | ## I Have a Question 9 | 10 | Before you ask a question read the available [documentation](https://github.com/lmaccherone/node-localstorage/blob/master/README.md) and search for existing [issues](https://github.com/lmaccherone/node-localstorage/issues) that might help you. In case you have found a suitable issue but need more clarification, you can write your question as a comment in the issue. 11 | 12 | If you then still need to ask a question, then feel free open an [Issue](https://github.com/lmaccherone/node-localstorage/issues/new). 13 | 14 | We will respond to the issue as soon as possible. 15 | 16 | 17 | ## I Want To Contribute 18 | 19 | > ### Legal Notice 20 | > Contributions must be free of any encumberance. Contributions are an attestation that you have the necessary authority to contribute it under the project license. By making a contribution of code or documentation, you agree to donate rights to the contribution to the project for the project to do with it whatever it wishes including but not limited to offering the project under a different license. 21 | 22 | ### Reporting Bugs 23 | 24 | > #### Security Issues 25 | > You must never report security related issues, including vulnerabilities or the presence of sensitive information, to the issue tracker or elsewhere in public. See [SECURITY.md](https://github.com/lmaccherone/node-localstorage/blob/master/SECURITY.md) for instructions on how to report security issues. 26 | 27 | We use GitHub issues to track bugs and errors. If you run into an issue with the project: 28 | 29 | - Open an [Issue](https://github.com/lmaccherone/node-localstorage/issues/new). 30 | - Explain the behavior you would expect and the actual behavior. 31 | - The working agreement for this project is that the first step in fixing a bug is reproducing it in an automated test case, so the ideal bug report includes a failing test case but at the very least should include enough information for someone to reproduce it and write a test case. If you can't reproduce it, we can't fix it. 32 | - Make sure that your preferences are set so that you are notified when the issue is updated. This will allow you to respond to any questions or requests for additional information. 33 | 34 | 35 | ### Suggesting Enhancements 36 | 37 | Enhancement suggestions are tracked as [GitHub issues](https://github.com/lmaccherone/node-localstorage/issues). 38 | 39 | Steps to suggest an enhancement: 40 | 41 | - Make sure that you are using the latest version. 42 | - Read the [documentation](https://github.com/lmaccherone/node-localstorage/blob/master/README.md) carefully and find out if the functionality is already covered, maybe with an optional parameter or configuration. 43 | - Perform a [search](https://github.com/lmaccherone/node-localstorage/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue in support rather than opening a new one. 44 | - Think about whether your idea fits with the scope and goals of the project. 45 | - Open an [Issue](https://github.com/lmaccherone/node-localstorage/issues/new). 46 | - Describe the enhancement and the motivation behind it. If your enhancement targets a minority of users or is backward breaking propose it as optional with additional parameters or configuration. 47 | 48 | 49 | ### Your First Contribution 50 | 51 | Use the steps below to make your first code or documentation contribution to the project: 52 | 53 | - Fork the [repository](https://github.com/lmaccherone/node-localstorage/fork) into your account. 54 | - Make your changes in your fork. 55 | - Be sure to keep the style consistent with the existing code or documentation. 56 | - If your contribution adds new functionality, make sure that you add tests for both the happy path and unexpected inputs. 57 | - If your contribution fixes a bug, start by writing a failing test the duplicates the bug, then modify the code so the test no longer fails. Then go back and write more tests to cover any other cases similar to the one you just fixed. 58 | 59 | 60 | ## Attribution 61 | This guide is based on the **contributing-gen**. [Make your own](https://github.com/bttger/contributing-gen)! 62 | -------------------------------------------------------------------------------- /Day20/node_modules/node-localstorage/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Lawrence S. Maccherone, Jr. 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 6 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 8 | to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 13 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 14 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 15 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 16 | IN THE SOFTWARE. -------------------------------------------------------------------------------- /Day20/node_modules/node-localstorage/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | I release patches for security vulnerabilities. Which versions are eligible 6 | receiving such patches depend on the CVSS v3.0 Rating: 7 | 8 | | CVSS v3.0 | Supported Versions | 9 | | --------- | ----------------------------------------- | 10 | | 9.0-10.0 | Releases within the previous three months | 11 | | 4.0-8.9 | Most recent release | 12 | 13 | ## Reporting a Vulnerability 14 | 15 | Please report (suspected) security vulnerabilities by private DM to 16 | [Larry on LinkedIn](https://www.linkedin.com/in/LarryMaccherone/). 17 | You will receive a response within 48 hours. If the issue is confirmed, 18 | I will release a patch as soon as possible depending on complexity 19 | but historically within a few days. 20 | -------------------------------------------------------------------------------- /Day20/node_modules/node-localstorage/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-localstorage", 3 | "version": "3.0.5", 4 | "main": "./LocalStorage", 5 | "description": "A drop-in substitute for the browser native localStorage API that runs on node.js.", 6 | "keywords": [ 7 | "localStorage", 8 | "Web Storage", 9 | "node.js" 10 | ], 11 | "author": { 12 | "name": "Larry Maccherone", 13 | "url": "https://www.LinkedIn.com/in/LarryMaccherone/" 14 | }, 15 | "homepage": "https://github.com/lmaccherone/node-localstorage", 16 | "engines": { 17 | "node": ">=0.12" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "http://github.com/lmaccherone/node-localstorage.git" 22 | }, 23 | "preferGlobal": false, 24 | "devDependencies": { 25 | "coffeescript": "^2.7.0", 26 | "coffeetape": "^2.0.0", 27 | "nyc": "^15.1.0", 28 | "tap-nyc": "^1.0.3", 29 | "tap-spec": "^5.0.0", 30 | "tape": "^5.6.6" 31 | }, 32 | "scripts": { 33 | "test": "npm run build && coffeetape test/*.coffee | tap-spec", 34 | "coverage": "npm run build && nyc --reporter=lcov coffeetape test/*.coffee | tap-nyc", 35 | "coverage:summary": "nyc report --reporter=text-summary", 36 | "coverage:report": "python3 -m http.server 3000 -d coverage/lcov-report", 37 | "publish:patch": "npm run test && npm version patch && npm publish", 38 | "publish:minor": "npm run test && npm version minor && npm publish", 39 | "publish:major": "npm run test && npm version major && npm publish", 40 | "postpublish": "git push --tags", 41 | "build": "coffee -c LocalStorage.coffee", 42 | "prepublishOnly": "coffee -c LocalStorage.coffee" 43 | }, 44 | "license": "MIT", 45 | "dependencies": { 46 | "write-file-atomic": "^5.0.1" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Day20/node_modules/node-localstorage/register.js: -------------------------------------------------------------------------------- 1 | if (typeof localStorage === "undefined" || localStorage === null) { 2 | const LocalStorage = require('node-localstorage').LocalStorage; 3 | global.localStorage = new LocalStorage('./scratch'); 4 | } 5 | -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The ISC License 2 | 3 | Copyright (c) 2015-2023 Benjamin Coe, Isaac Z. Schlueter, and Contributors 4 | 5 | Permission to use, copy, modify, and/or distribute this software 6 | for any purpose with or without fee is hereby granted, provided 7 | that the above copyright notice and this permission notice 8 | appear in all copies. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 12 | OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE 13 | LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES 14 | OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 15 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 16 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/README.md: -------------------------------------------------------------------------------- 1 | # signal-exit 2 | 3 | When you want to fire an event no matter how a process exits: 4 | 5 | - reaching the end of execution. 6 | - explicitly having `process.exit(code)` called. 7 | - having `process.kill(pid, sig)` called. 8 | - receiving a fatal signal from outside the process 9 | 10 | Use `signal-exit`. 11 | 12 | ```js 13 | // Hybrid module, either works 14 | import { onExit } from 'signal-exit' 15 | // or: 16 | // const { onExit } = require('signal-exit') 17 | 18 | onExit((code, signal) => { 19 | console.log('process exited!', code, signal) 20 | }) 21 | ``` 22 | 23 | ## API 24 | 25 | `remove = onExit((code, signal) => {}, options)` 26 | 27 | The return value of the function is a function that will remove 28 | the handler. 29 | 30 | Note that the function _only_ fires for signals if the signal 31 | would cause the process to exit. That is, there are no other 32 | listeners, and it is a fatal signal. 33 | 34 | If the global `process` object is not suitable for this purpose 35 | (ie, it's unset, or doesn't have an `emit` method, etc.) then the 36 | `onExit` function is a no-op that returns a no-op `remove` method. 37 | 38 | ### Options 39 | 40 | - `alwaysLast`: Run this handler after any other signal or exit 41 | handlers. This causes `process.emit` to be monkeypatched. 42 | 43 | ### Capturing Signal Exits 44 | 45 | If the handler returns an exact boolean `true`, and the exit is a 46 | due to signal, then the signal will be considered handled, and 47 | will _not_ trigger a synthetic `process.kill(process.pid, 48 | signal)` after firing the `onExit` handlers. 49 | 50 | In this case, it your responsibility as the caller to exit with a 51 | signal (for example, by calling `process.kill()`) if you wish to 52 | preserve the same exit status that would otherwise have occurred. 53 | If you do not, then the process will likely exit gracefully with 54 | status 0 at some point, assuming that no other terminating signal 55 | or other exit trigger occurs. 56 | 57 | Prior to calling handlers, the `onExit` machinery is unloaded, so 58 | any subsequent exits or signals will not be handled, even if the 59 | signal is captured and the exit is thus prevented. 60 | 61 | Note that numeric code exits may indicate that the process is 62 | already committed to exiting, for example due to a fatal 63 | exception or unhandled promise rejection, and so there is no way to 64 | prevent it safely. 65 | 66 | ### Browser Fallback 67 | 68 | The `'signal-exit/browser'` module is the same fallback shim that 69 | just doesn't do anything, but presents the same function 70 | interface. 71 | 72 | Patches welcome to add something that hooks onto 73 | `window.onbeforeunload` or similar, but it might just not be a 74 | thing that makes sense there. 75 | -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/cjs/browser.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a browser shim that provides the same functional interface 3 | * as the main node export, but it does nothing. 4 | * @module 5 | */ 6 | import type { Handler } from './index.js'; 7 | export declare const onExit: (cb: Handler, opts: { 8 | alwaysLast?: boolean; 9 | }) => () => void; 10 | export declare const load: () => void; 11 | export declare const unload: () => void; 12 | //# sourceMappingURL=browser.d.ts.map -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/cjs/browser.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACzC,eAAO,MAAM,MAAM,EAAE,CACnB,EAAE,EAAE,OAAO,EACX,IAAI,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,KAC3B,MAAM,IAAqB,CAAA;AAChC,eAAO,MAAM,IAAI,YAAW,CAAA;AAC5B,eAAO,MAAM,MAAM,YAAW,CAAA"} -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/cjs/browser.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.unload = exports.load = exports.onExit = void 0; 4 | const onExit = () => () => { }; 5 | exports.onExit = onExit; 6 | const load = () => { }; 7 | exports.load = load; 8 | const unload = () => { }; 9 | exports.unload = unload; 10 | //# sourceMappingURL=browser.js.map -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/cjs/browser.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":";;;AAMO,MAAM,MAAM,GAGD,GAAG,EAAE,CAAC,GAAG,EAAE,GAAE,CAAC,CAAA;AAHnB,QAAA,MAAM,UAGa;AACzB,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;AAAf,QAAA,IAAI,QAAW;AACrB,MAAM,MAAM,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;AAAjB,QAAA,MAAM,UAAW","sourcesContent":["/**\n * This is a browser shim that provides the same functional interface\n * as the main node export, but it does nothing.\n * @module\n */\nimport type { Handler } from './index.js'\nexport const onExit: (\n cb: Handler,\n opts: { alwaysLast?: boolean }\n) => () => void = () => () => {}\nexport const load = () => {}\nexport const unload = () => {}\n"]} -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/cjs/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import { signals } from './signals.js'; 3 | export { signals }; 4 | /** 5 | * A function that takes an exit code and signal as arguments 6 | * 7 | * In the case of signal exits *only*, a return value of true 8 | * will indicate that the signal is being handled, and we should 9 | * not synthetically exit with the signal we received. Regardless 10 | * of the handler return value, the handler is unloaded when an 11 | * otherwise fatal signal is received, so you get exactly 1 shot 12 | * at it, unless you add another onExit handler at that point. 13 | * 14 | * In the case of numeric code exits, we may already have committed 15 | * to exiting the process, for example via a fatal exception or 16 | * unhandled promise rejection, so it is impossible to stop safely. 17 | */ 18 | export type Handler = (code: number | null | undefined, signal: NodeJS.Signals | null) => true | void; 19 | export declare const 20 | /** 21 | * Called when the process is exiting, whether via signal, explicit 22 | * exit, or running out of stuff to do. 23 | * 24 | * If the global process object is not suitable for instrumentation, 25 | * then this will be a no-op. 26 | * 27 | * Returns a function that may be used to unload signal-exit. 28 | */ 29 | onExit: (cb: Handler, opts?: { 30 | alwaysLast?: boolean | undefined; 31 | } | undefined) => () => void, 32 | /** 33 | * Load the listeners. Likely you never need to call this, unless 34 | * doing a rather deep integration with signal-exit functionality. 35 | * Mostly exposed for the benefit of testing. 36 | * 37 | * @internal 38 | */ 39 | load: () => void, 40 | /** 41 | * Unload the listeners. Likely you never need to call this, unless 42 | * doing a rather deep integration with signal-exit functionality. 43 | * Mostly exposed for the benefit of testing. 44 | * 45 | * @internal 46 | */ 47 | unload: () => void; 48 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/cjs/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,CAAA;AAuBlB;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,OAAO,GAAG,CACpB,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,KAC1B,IAAI,GAAG,IAAI,CAAA;AA8QhB,eAAO;AACL;;;;;;;;GAQG;AACH,MAAM,OAzMO,OAAO;;wBAPiD,IAAI;AAkNzE;;;;;;GAMG;AACH,IAAI;AAEJ;;;;;;GAMG;AACH,MAAM,YAGP,CAAA"} -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/cjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "commonjs" 3 | } 4 | -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/cjs/signals.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /** 3 | * This is not the set of all possible signals. 4 | * 5 | * It IS, however, the set of all signals that trigger 6 | * an exit on either Linux or BSD systems. Linux is a 7 | * superset of the signal names supported on BSD, and 8 | * the unknown signals just fail to register, so we can 9 | * catch that easily enough. 10 | * 11 | * Windows signals are a different set, since there are 12 | * signals that terminate Windows processes, but don't 13 | * terminate (or don't even exist) on Posix systems. 14 | * 15 | * Don't bother with SIGKILL. It's uncatchable, which 16 | * means that we can't fire any callbacks anyway. 17 | * 18 | * If a user does happen to register a handler on a non- 19 | * fatal signal like SIGWINCH or something, and then 20 | * exit, it'll end up firing `process.emit('exit')`, so 21 | * the handler will be fired anyway. 22 | * 23 | * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised 24 | * artificially, inherently leave the process in a 25 | * state from which it is not safe to try and enter JS 26 | * listeners. 27 | */ 28 | export declare const signals: NodeJS.Signals[]; 29 | //# sourceMappingURL=signals.d.ts.map -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/cjs/signals.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/signals.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,OAAO,EAAO,CAAA"} -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/cjs/signals.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.signals = void 0; 4 | /** 5 | * This is not the set of all possible signals. 6 | * 7 | * It IS, however, the set of all signals that trigger 8 | * an exit on either Linux or BSD systems. Linux is a 9 | * superset of the signal names supported on BSD, and 10 | * the unknown signals just fail to register, so we can 11 | * catch that easily enough. 12 | * 13 | * Windows signals are a different set, since there are 14 | * signals that terminate Windows processes, but don't 15 | * terminate (or don't even exist) on Posix systems. 16 | * 17 | * Don't bother with SIGKILL. It's uncatchable, which 18 | * means that we can't fire any callbacks anyway. 19 | * 20 | * If a user does happen to register a handler on a non- 21 | * fatal signal like SIGWINCH or something, and then 22 | * exit, it'll end up firing `process.emit('exit')`, so 23 | * the handler will be fired anyway. 24 | * 25 | * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised 26 | * artificially, inherently leave the process in a 27 | * state from which it is not safe to try and enter JS 28 | * listeners. 29 | */ 30 | exports.signals = []; 31 | exports.signals.push('SIGHUP', 'SIGINT', 'SIGTERM'); 32 | if (process.platform !== 'win32') { 33 | exports.signals.push('SIGALRM', 'SIGABRT', 'SIGVTALRM', 'SIGXCPU', 'SIGXFSZ', 'SIGUSR2', 'SIGTRAP', 'SIGSYS', 'SIGQUIT', 'SIGIOT' 34 | // should detect profiler and enable/disable accordingly. 35 | // see #21 36 | // 'SIGPROF' 37 | ); 38 | } 39 | if (process.platform === 'linux') { 40 | exports.signals.push('SIGIO', 'SIGPOLL', 'SIGPWR', 'SIGSTKFLT'); 41 | } 42 | //# sourceMappingURL=signals.js.map -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/cjs/signals.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"signals.js","sourceRoot":"","sources":["../../src/signals.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACU,QAAA,OAAO,GAAqB,EAAE,CAAA;AAC3C,eAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAA;AAE3C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;IAChC,eAAO,CAAC,IAAI,CACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,EACR,SAAS,EACT,QAAQ;IACR,yDAAyD;IACzD,UAAU;IACV,YAAY;KACb,CAAA;CACF;AAED,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;IAChC,eAAO,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAA;CACxD","sourcesContent":["/**\n * This is not the set of all possible signals.\n *\n * It IS, however, the set of all signals that trigger\n * an exit on either Linux or BSD systems. Linux is a\n * superset of the signal names supported on BSD, and\n * the unknown signals just fail to register, so we can\n * catch that easily enough.\n *\n * Windows signals are a different set, since there are\n * signals that terminate Windows processes, but don't\n * terminate (or don't even exist) on Posix systems.\n *\n * Don't bother with SIGKILL. It's uncatchable, which\n * means that we can't fire any callbacks anyway.\n *\n * If a user does happen to register a handler on a non-\n * fatal signal like SIGWINCH or something, and then\n * exit, it'll end up firing `process.emit('exit')`, so\n * the handler will be fired anyway.\n *\n * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised\n * artificially, inherently leave the process in a\n * state from which it is not safe to try and enter JS\n * listeners.\n */\nexport const signals: NodeJS.Signals[] = []\nsignals.push('SIGHUP', 'SIGINT', 'SIGTERM')\n\nif (process.platform !== 'win32') {\n signals.push(\n 'SIGALRM',\n 'SIGABRT',\n 'SIGVTALRM',\n 'SIGXCPU',\n 'SIGXFSZ',\n 'SIGUSR2',\n 'SIGTRAP',\n 'SIGSYS',\n 'SIGQUIT',\n 'SIGIOT'\n // should detect profiler and enable/disable accordingly.\n // see #21\n // 'SIGPROF'\n )\n}\n\nif (process.platform === 'linux') {\n signals.push('SIGIO', 'SIGPOLL', 'SIGPWR', 'SIGSTKFLT')\n}\n"]} -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/mjs/browser.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a browser shim that provides the same functional interface 3 | * as the main node export, but it does nothing. 4 | * @module 5 | */ 6 | import type { Handler } from './index.js'; 7 | export declare const onExit: (cb: Handler, opts: { 8 | alwaysLast?: boolean; 9 | }) => () => void; 10 | export declare const load: () => void; 11 | export declare const unload: () => void; 12 | //# sourceMappingURL=browser.d.ts.map -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/mjs/browser.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACzC,eAAO,MAAM,MAAM,EAAE,CACnB,EAAE,EAAE,OAAO,EACX,IAAI,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,KAC3B,MAAM,IAAqB,CAAA;AAChC,eAAO,MAAM,IAAI,YAAW,CAAA;AAC5B,eAAO,MAAM,MAAM,YAAW,CAAA"} -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/mjs/browser.js: -------------------------------------------------------------------------------- 1 | export const onExit = () => () => { }; 2 | export const load = () => { }; 3 | export const unload = () => { }; 4 | //# sourceMappingURL=browser.js.map -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/mjs/browser.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,MAAM,GAGD,GAAG,EAAE,CAAC,GAAG,EAAE,GAAE,CAAC,CAAA;AAChC,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;AAC5B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA","sourcesContent":["/**\n * This is a browser shim that provides the same functional interface\n * as the main node export, but it does nothing.\n * @module\n */\nimport type { Handler } from './index.js'\nexport const onExit: (\n cb: Handler,\n opts: { alwaysLast?: boolean }\n) => () => void = () => () => {}\nexport const load = () => {}\nexport const unload = () => {}\n"]} -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/mjs/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import { signals } from './signals.js'; 3 | export { signals }; 4 | /** 5 | * A function that takes an exit code and signal as arguments 6 | * 7 | * In the case of signal exits *only*, a return value of true 8 | * will indicate that the signal is being handled, and we should 9 | * not synthetically exit with the signal we received. Regardless 10 | * of the handler return value, the handler is unloaded when an 11 | * otherwise fatal signal is received, so you get exactly 1 shot 12 | * at it, unless you add another onExit handler at that point. 13 | * 14 | * In the case of numeric code exits, we may already have committed 15 | * to exiting the process, for example via a fatal exception or 16 | * unhandled promise rejection, so it is impossible to stop safely. 17 | */ 18 | export type Handler = (code: number | null | undefined, signal: NodeJS.Signals | null) => true | void; 19 | export declare const 20 | /** 21 | * Called when the process is exiting, whether via signal, explicit 22 | * exit, or running out of stuff to do. 23 | * 24 | * If the global process object is not suitable for instrumentation, 25 | * then this will be a no-op. 26 | * 27 | * Returns a function that may be used to unload signal-exit. 28 | */ 29 | onExit: (cb: Handler, opts?: { 30 | alwaysLast?: boolean | undefined; 31 | } | undefined) => () => void, 32 | /** 33 | * Load the listeners. Likely you never need to call this, unless 34 | * doing a rather deep integration with signal-exit functionality. 35 | * Mostly exposed for the benefit of testing. 36 | * 37 | * @internal 38 | */ 39 | load: () => void, 40 | /** 41 | * Unload the listeners. Likely you never need to call this, unless 42 | * doing a rather deep integration with signal-exit functionality. 43 | * Mostly exposed for the benefit of testing. 44 | * 45 | * @internal 46 | */ 47 | unload: () => void; 48 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/mjs/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,CAAA;AAuBlB;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,OAAO,GAAG,CACpB,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,KAC1B,IAAI,GAAG,IAAI,CAAA;AA8QhB,eAAO;AACL;;;;;;;;GAQG;AACH,MAAM,OAzMO,OAAO;;wBAPiD,IAAI;AAkNzE;;;;;;GAMG;AACH,IAAI;AAEJ;;;;;;GAMG;AACH,MAAM,YAGP,CAAA"} -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/mjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/mjs/signals.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /** 3 | * This is not the set of all possible signals. 4 | * 5 | * It IS, however, the set of all signals that trigger 6 | * an exit on either Linux or BSD systems. Linux is a 7 | * superset of the signal names supported on BSD, and 8 | * the unknown signals just fail to register, so we can 9 | * catch that easily enough. 10 | * 11 | * Windows signals are a different set, since there are 12 | * signals that terminate Windows processes, but don't 13 | * terminate (or don't even exist) on Posix systems. 14 | * 15 | * Don't bother with SIGKILL. It's uncatchable, which 16 | * means that we can't fire any callbacks anyway. 17 | * 18 | * If a user does happen to register a handler on a non- 19 | * fatal signal like SIGWINCH or something, and then 20 | * exit, it'll end up firing `process.emit('exit')`, so 21 | * the handler will be fired anyway. 22 | * 23 | * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised 24 | * artificially, inherently leave the process in a 25 | * state from which it is not safe to try and enter JS 26 | * listeners. 27 | */ 28 | export declare const signals: NodeJS.Signals[]; 29 | //# sourceMappingURL=signals.d.ts.map -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/mjs/signals.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/signals.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,OAAO,EAAO,CAAA"} -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/mjs/signals.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This is not the set of all possible signals. 3 | * 4 | * It IS, however, the set of all signals that trigger 5 | * an exit on either Linux or BSD systems. Linux is a 6 | * superset of the signal names supported on BSD, and 7 | * the unknown signals just fail to register, so we can 8 | * catch that easily enough. 9 | * 10 | * Windows signals are a different set, since there are 11 | * signals that terminate Windows processes, but don't 12 | * terminate (or don't even exist) on Posix systems. 13 | * 14 | * Don't bother with SIGKILL. It's uncatchable, which 15 | * means that we can't fire any callbacks anyway. 16 | * 17 | * If a user does happen to register a handler on a non- 18 | * fatal signal like SIGWINCH or something, and then 19 | * exit, it'll end up firing `process.emit('exit')`, so 20 | * the handler will be fired anyway. 21 | * 22 | * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised 23 | * artificially, inherently leave the process in a 24 | * state from which it is not safe to try and enter JS 25 | * listeners. 26 | */ 27 | export const signals = []; 28 | signals.push('SIGHUP', 'SIGINT', 'SIGTERM'); 29 | if (process.platform !== 'win32') { 30 | signals.push('SIGALRM', 'SIGABRT', 'SIGVTALRM', 'SIGXCPU', 'SIGXFSZ', 'SIGUSR2', 'SIGTRAP', 'SIGSYS', 'SIGQUIT', 'SIGIOT' 31 | // should detect profiler and enable/disable accordingly. 32 | // see #21 33 | // 'SIGPROF' 34 | ); 35 | } 36 | if (process.platform === 'linux') { 37 | signals.push('SIGIO', 'SIGPOLL', 'SIGPWR', 'SIGSTKFLT'); 38 | } 39 | //# sourceMappingURL=signals.js.map -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/dist/mjs/signals.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"signals.js","sourceRoot":"","sources":["../../src/signals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAqB,EAAE,CAAA;AAC3C,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAA;AAE3C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;IAChC,OAAO,CAAC,IAAI,CACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,EACR,SAAS,EACT,QAAQ;IACR,yDAAyD;IACzD,UAAU;IACV,YAAY;KACb,CAAA;CACF;AAED,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;IAChC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAA;CACxD","sourcesContent":["/**\n * This is not the set of all possible signals.\n *\n * It IS, however, the set of all signals that trigger\n * an exit on either Linux or BSD systems. Linux is a\n * superset of the signal names supported on BSD, and\n * the unknown signals just fail to register, so we can\n * catch that easily enough.\n *\n * Windows signals are a different set, since there are\n * signals that terminate Windows processes, but don't\n * terminate (or don't even exist) on Posix systems.\n *\n * Don't bother with SIGKILL. It's uncatchable, which\n * means that we can't fire any callbacks anyway.\n *\n * If a user does happen to register a handler on a non-\n * fatal signal like SIGWINCH or something, and then\n * exit, it'll end up firing `process.emit('exit')`, so\n * the handler will be fired anyway.\n *\n * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised\n * artificially, inherently leave the process in a\n * state from which it is not safe to try and enter JS\n * listeners.\n */\nexport const signals: NodeJS.Signals[] = []\nsignals.push('SIGHUP', 'SIGINT', 'SIGTERM')\n\nif (process.platform !== 'win32') {\n signals.push(\n 'SIGALRM',\n 'SIGABRT',\n 'SIGVTALRM',\n 'SIGXCPU',\n 'SIGXFSZ',\n 'SIGUSR2',\n 'SIGTRAP',\n 'SIGSYS',\n 'SIGQUIT',\n 'SIGIOT'\n // should detect profiler and enable/disable accordingly.\n // see #21\n // 'SIGPROF'\n )\n}\n\nif (process.platform === 'linux') {\n signals.push('SIGIO', 'SIGPOLL', 'SIGPWR', 'SIGSTKFLT')\n}\n"]} -------------------------------------------------------------------------------- /Day20/node_modules/signal-exit/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "signal-exit", 3 | "version": "4.1.0", 4 | "description": "when you want to fire an event no matter how a process exits.", 5 | "main": "./dist/cjs/index.js", 6 | "module": "./dist/mjs/index.js", 7 | "browser": "./dist/mjs/browser.js", 8 | "types": "./dist/mjs/index.d.ts", 9 | "exports": { 10 | ".": { 11 | "import": { 12 | "types": "./dist/mjs/index.d.ts", 13 | "default": "./dist/mjs/index.js" 14 | }, 15 | "require": { 16 | "types": "./dist/cjs/index.d.ts", 17 | "default": "./dist/cjs/index.js" 18 | } 19 | }, 20 | "./signals": { 21 | "import": { 22 | "types": "./dist/mjs/signals.d.ts", 23 | "default": "./dist/mjs/signals.js" 24 | }, 25 | "require": { 26 | "types": "./dist/cjs/signals.d.ts", 27 | "default": "./dist/cjs/signals.js" 28 | } 29 | }, 30 | "./browser": { 31 | "import": { 32 | "types": "./dist/mjs/browser.d.ts", 33 | "default": "./dist/mjs/browser.js" 34 | }, 35 | "require": { 36 | "types": "./dist/cjs/browser.d.ts", 37 | "default": "./dist/cjs/browser.js" 38 | } 39 | } 40 | }, 41 | "files": [ 42 | "dist" 43 | ], 44 | "engines": { 45 | "node": ">=14" 46 | }, 47 | "repository": { 48 | "type": "git", 49 | "url": "https://github.com/tapjs/signal-exit.git" 50 | }, 51 | "keywords": [ 52 | "signal", 53 | "exit" 54 | ], 55 | "author": "Ben Coe ", 56 | "license": "ISC", 57 | "devDependencies": { 58 | "@types/cross-spawn": "^6.0.2", 59 | "@types/node": "^18.15.11", 60 | "@types/signal-exit": "^3.0.1", 61 | "@types/tap": "^15.0.8", 62 | "c8": "^7.13.0", 63 | "prettier": "^2.8.6", 64 | "tap": "^16.3.4", 65 | "ts-node": "^10.9.1", 66 | "typedoc": "^0.23.28", 67 | "typescript": "^5.0.2" 68 | }, 69 | "scripts": { 70 | "preversion": "npm test", 71 | "postversion": "npm publish", 72 | "prepublishOnly": "git push origin --follow-tags", 73 | "preprepare": "rm -rf dist", 74 | "prepare": "tsc -p tsconfig.json && tsc -p tsconfig-esm.json && bash ./scripts/fixup.sh", 75 | "pretest": "npm run prepare", 76 | "presnap": "npm run prepare", 77 | "test": "c8 tap", 78 | "snap": "c8 tap", 79 | "format": "prettier --write . --loglevel warn", 80 | "typedoc": "typedoc --tsconfig tsconfig-esm.json ./src/*.ts" 81 | }, 82 | "prettier": { 83 | "semi": false, 84 | "printWidth": 75, 85 | "tabWidth": 2, 86 | "useTabs": false, 87 | "singleQuote": true, 88 | "jsxSingleQuote": false, 89 | "bracketSameLine": true, 90 | "arrowParens": "avoid", 91 | "endOfLine": "lf" 92 | }, 93 | "tap": { 94 | "coverage": false, 95 | "jobs": 1, 96 | "node-arg": [ 97 | "--no-warnings", 98 | "--loader", 99 | "ts-node/esm" 100 | ], 101 | "ts": false 102 | }, 103 | "funding": { 104 | "url": "https://github.com/sponsors/isaacs" 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Day20/node_modules/write-file-atomic/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Rebecca Turner 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 6 | 7 | -------------------------------------------------------------------------------- /Day20/node_modules/write-file-atomic/README.md: -------------------------------------------------------------------------------- 1 | write-file-atomic 2 | ----------------- 3 | 4 | This is an extension for node's `fs.writeFile` that makes its operation 5 | atomic and allows you set ownership (uid/gid of the file). 6 | 7 | ### `writeFileAtomic(filename, data, [options], [callback])` 8 | 9 | #### Description: 10 | 11 | Atomically and asynchronously writes data to a file, replacing the file if it already 12 | exists. data can be a string or a buffer. 13 | 14 | #### Options: 15 | * filename **String** 16 | * data **String** | **Buffer** 17 | * options **Object** | **String** 18 | * chown **Object** default, uid & gid of existing file, if any 19 | * uid **Number** 20 | * gid **Number** 21 | * encoding **String** | **Null** default = 'utf8' 22 | * fsync **Boolean** default = true 23 | * mode **Number** default, from existing file, if any 24 | * tmpfileCreated **Function** called when the tmpfile is created 25 | * callback **Function** 26 | 27 | #### Usage: 28 | 29 | ```js 30 | var writeFileAtomic = require('write-file-atomic') 31 | writeFileAtomic(filename, data, [options], [callback]) 32 | ``` 33 | 34 | The file is initially named `filename + "." + murmurhex(__filename, process.pid, ++invocations)`. 35 | Note that `require('worker_threads').threadId` is used in addition to `process.pid` if running inside of a worker thread. 36 | If writeFile completes successfully then, if passed the **chown** option it will change 37 | the ownership of the file. Finally it renames the file back to the filename you specified. If 38 | it encounters errors at any of these steps it will attempt to unlink the temporary file and then 39 | pass the error back to the caller. 40 | If multiple writes are concurrently issued to the same file, the write operations are put into a queue and serialized in the order they were called, using Promises. Writes to different files are still executed in parallel. 41 | 42 | If provided, the **chown** option requires both **uid** and **gid** properties or else 43 | you'll get an error. If **chown** is not specified it will default to using 44 | the owner of the previous file. To prevent chown from being ran you can 45 | also pass `false`, in which case the file will be created with the current user's credentials. 46 | 47 | If **mode** is not specified, it will default to using the permissions from 48 | an existing file, if any. Expicitly setting this to `false` remove this default, resulting 49 | in a file created with the system default permissions. 50 | 51 | If options is a String, it's assumed to be the **encoding** option. The **encoding** option is ignored if **data** is a buffer. It defaults to 'utf8'. 52 | 53 | If the **fsync** option is **false**, writeFile will skip the final fsync call. 54 | 55 | If the **tmpfileCreated** option is specified it will be called with the name of the tmpfile when created. 56 | 57 | Example: 58 | 59 | ```javascript 60 | writeFileAtomic('message.txt', 'Hello Node', {chown:{uid:100,gid:50}}, function (err) { 61 | if (err) throw err; 62 | console.log('It\'s saved!'); 63 | }); 64 | ``` 65 | 66 | This function also supports async/await: 67 | 68 | ```javascript 69 | (async () => { 70 | try { 71 | await writeFileAtomic('message.txt', 'Hello Node', {chown:{uid:100,gid:50}}); 72 | console.log('It\'s saved!'); 73 | } catch (err) { 74 | console.error(err); 75 | process.exit(1); 76 | } 77 | })(); 78 | ``` 79 | 80 | ### `writeFileAtomicSync(filename, data, [options])` 81 | 82 | #### Description: 83 | 84 | The synchronous version of **writeFileAtomic**. 85 | 86 | #### Usage: 87 | ```js 88 | var writeFileAtomicSync = require('write-file-atomic').sync 89 | writeFileAtomicSync(filename, data, [options]) 90 | ``` 91 | 92 | -------------------------------------------------------------------------------- /Day20/node_modules/write-file-atomic/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "write-file-atomic", 3 | "version": "5.0.1", 4 | "description": "Write files in an atomic fashion w/configurable ownership", 5 | "main": "./lib/index.js", 6 | "scripts": { 7 | "test": "tap", 8 | "posttest": "npm run lint", 9 | "lint": "eslint \"**/*.js\"", 10 | "postlint": "template-oss-check", 11 | "lintfix": "npm run lint -- --fix", 12 | "snap": "tap", 13 | "template-oss-apply": "template-oss-apply --force" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/npm/write-file-atomic.git" 18 | }, 19 | "keywords": [ 20 | "writeFile", 21 | "atomic" 22 | ], 23 | "author": "GitHub Inc.", 24 | "license": "ISC", 25 | "bugs": { 26 | "url": "https://github.com/npm/write-file-atomic/issues" 27 | }, 28 | "homepage": "https://github.com/npm/write-file-atomic", 29 | "dependencies": { 30 | "imurmurhash": "^0.1.4", 31 | "signal-exit": "^4.0.1" 32 | }, 33 | "devDependencies": { 34 | "@npmcli/eslint-config": "^4.0.0", 35 | "@npmcli/template-oss": "4.14.1", 36 | "tap": "^16.0.1" 37 | }, 38 | "files": [ 39 | "bin/", 40 | "lib/" 41 | ], 42 | "engines": { 43 | "node": "^14.17.0 || ^16.13.0 || >=18.0.0" 44 | }, 45 | "templateOSS": { 46 | "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", 47 | "windowsCI": false, 48 | "version": "4.14.1", 49 | "publish": "true" 50 | }, 51 | "tap": { 52 | "nyc-arg": [ 53 | "--exclude", 54 | "tap-snapshots/**" 55 | ] 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Day20/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Day20", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": { 6 | "": { 7 | "dependencies": { 8 | "node-localstorage": "^3.0.5" 9 | } 10 | }, 11 | "node_modules/imurmurhash": { 12 | "version": "0.1.4", 13 | "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", 14 | "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", 15 | "license": "MIT", 16 | "engines": { 17 | "node": ">=0.8.19" 18 | } 19 | }, 20 | "node_modules/node-localstorage": { 21 | "version": "3.0.5", 22 | "resolved": "https://registry.npmjs.org/node-localstorage/-/node-localstorage-3.0.5.tgz", 23 | "integrity": "sha512-GCwtK33iwVXboZWYcqQHu3aRvXEBwmPkAMRBLeaX86ufhqslyUkLGsi4aW3INEfdQYpUB5M9qtYf3eHvAk2VBg==", 24 | "license": "MIT", 25 | "dependencies": { 26 | "write-file-atomic": "^5.0.1" 27 | }, 28 | "engines": { 29 | "node": ">=0.12" 30 | } 31 | }, 32 | "node_modules/signal-exit": { 33 | "version": "4.1.0", 34 | "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", 35 | "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", 36 | "license": "ISC", 37 | "engines": { 38 | "node": ">=14" 39 | }, 40 | "funding": { 41 | "url": "https://github.com/sponsors/isaacs" 42 | } 43 | }, 44 | "node_modules/write-file-atomic": { 45 | "version": "5.0.1", 46 | "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", 47 | "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", 48 | "license": "ISC", 49 | "dependencies": { 50 | "imurmurhash": "^0.1.4", 51 | "signal-exit": "^4.0.1" 52 | }, 53 | "engines": { 54 | "node": "^14.17.0 || ^16.13.0 || >=18.0.0" 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Day20/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "node-localstorage": "^3.0.5" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /Day20/scratch/myObjectKey: -------------------------------------------------------------------------------- 1 | {"name":"Yash","age":24,"profession":"Software Engineer"} -------------------------------------------------------------------------------- /Day20/scratch/myStringKey: -------------------------------------------------------------------------------- 1 | Hello, World! -------------------------------------------------------------------------------- /Day20/scratch/username: -------------------------------------------------------------------------------- 1 | Yash K. Saini -------------------------------------------------------------------------------- /Day20/session/greeting: -------------------------------------------------------------------------------- 1 | Hello, Node.js! -------------------------------------------------------------------------------- /Day20/session/user: -------------------------------------------------------------------------------- 1 | {"name":"Yash K. Saini","email":"yashkumarsaini101@gmail.com","age":20} -------------------------------------------------------------------------------- /Day20/session/username: -------------------------------------------------------------------------------- 1 | Yash K. Saini -------------------------------------------------------------------------------- /Day21/Task.md: -------------------------------------------------------------------------------- 1 | # Day 21: LeetCode Easy Problems 🚀 2 | 3 | Welcome to Day 21! Today, we're tackling some classic problems on LeetCode. These exercises will help you sharpen your problem-solving skills and build confidence in solving coding challenges. Let's dive into it! 💪 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Two Sum ➕ 8 | - [X] **Task 1:** Solve the "Two Sum" problem on LeetCode. 9 | - Write a function that takes an array of numbers and a target number, and returns the indices of the two numbers that add up to the target. 10 | - Log the indices for a few test cases. 11 | 12 | ### Activity 2: Reverse Integer 🔄 13 | - [X] **Task 2:** Solve the "Reverse Integer" problem on LeetCode. 14 | - Write a function that takes an integer and returns it with its digits reversed. 15 | - Handle edge cases like negative numbers and numbers ending in zero. 16 | - Log the reversed integers for a few test cases. 17 | 18 | ### Activity 3: Palindrome Number 🔢 19 | - [X] **Task 3:** Solve the "Palindrome Number" problem on LeetCode. 20 | - Write a function that takes an integer and returns `true` if it is a palindrome, and `false` otherwise. 21 | - Log the result for a few test cases, including edge cases like negative numbers. 22 | 23 | ### Activity 4: Merge Two Sorted Lists 🔗 24 | - [X] **Task 4:** Solve the "Merge Two Sorted Lists" problem on LeetCode. 25 | - Write a function that takes two sorted linked lists and returns a new sorted list by merging them. 26 | - Create a few test cases with linked lists and log the merged list. 27 | 28 | ### Activity 5: Valid Parentheses ✔️❌ 29 | - [X] **Task 5:** Solve the "Valid Parentheses" problem on LeetCode. 30 | - Write a function that takes a string containing just the characters '(', ')', '[', ']', '{', '}', and determines if the input string is valid. 31 | - A string is valid if open brackets are closed in the correct order. 32 | - Log the result for a few test cases. 33 | 34 | ## Feature Request 🎯 35 | 36 | 1. **Two Sum Script:** Write a script that includes a function to solve the "Two Sum" problem and logs the indices of the two numbers. 37 | 2. **Reverse Integer Script:** Create a script that includes a function to reverse an integer and handles edge cases. 38 | 3. **Palindrome Number Script:** Write a script that includes a function to check if an integer is a palindrome and logs the result. 39 | 4. **Merge Two Sorted Lists Script:** Create a script that includes a function to merge two sorted linked lists and logs the merged list. 40 | 5. **Valid Parentheses Script:** Write a script that includes a function to check if a string of parentheses is valid and logs the result. 41 | 42 | ## Achievement Unlocked 🏆 43 | 44 | By the end of these activities, you will: 45 | 46 | - ✅ Solve common LeetCode problems. 47 | - ✅ Apply problem-solving skills to implement algorithms. 48 | - ✅ Understand and handle edge cases in algorithmic solutions. 49 | - ✅ Gain confidence in solving easy-level coding challenges on LeetCode. 50 | 51 | --- 52 | 53 | Happy Coding! 💻✨ -------------------------------------------------------------------------------- /Day22/Task.md: -------------------------------------------------------------------------------- 1 | # Day 22: LeetCode Medium Problems 🚀 2 | 3 | Welcome to Day 22! Today, we'll be tackling some medium-level challenges on LeetCode. These problems will push your problem-solving abilities and help you become more comfortable with advanced algorithms. Let's get started! 💪 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Add Two Numbers ➕ 8 | - [X] **Task 1:** Solve the "Add Two Numbers" problem on LeetCode. 9 | - Write a function that takes two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each node contains a single digit. Add the two numbers and return the sum as a linked list. 10 | - Create a few test cases with linked lists and log the sum as a linked list. 11 | 12 | ### Activity 2: Longest Substring Without Repeating Characters 🔤 13 | - [X] **Task 2:** Solve the "Longest Substring Without Repeating Characters" problem on LeetCode. 14 | - Write a function that takes a string and returns the length of the longest substring without repeating characters. 15 | - Log the length for a few test cases, including edge cases. 16 | 17 | ### Activity 3: Container With Most Water 💧 18 | - [X] **Task 3:** Solve the "Container With Most Water" problem on LeetCode. 19 | - Write a function that takes an array of non-negative integers where each integer represents the height of a line drawn at each point. Find two lines that, together with the x-axis, form a container such that the container holds the most water. 20 | - Log the maximum amount of water for a few test cases. 21 | 22 | ### Activity 4: 3Sum 🌐 23 | - [X] **Task 4:** Solve the "3Sum" problem on LeetCode. 24 | - Write a function that takes an array of integers and finds all unique triplets in the array which sum to zero. 25 | - Log the triplets for a few test cases, including edge cases. 26 | 27 | ### Activity 5: Group Anagrams 🅰️🅱️🅾️ 28 | - [X] **Task 5:** Solve the "Group Anagrams" problem on LeetCode. 29 | - Write a function that takes an array of strings and groups anagrams together. 30 | - Log the grouped anagrams for a few test cases. 31 | 32 | ## Feature Request 🎯 33 | 34 | 1. **Add Two Numbers Script:** Write a script that includes a function to solve the "Add Two Numbers" problem and logs the sum as a linked list. 35 | 2. **Longest Substring Script:** Create a script that includes a function to find the longest substring without repeating characters and logs the length. 36 | 3. **Container With Most Water Script:** Write a script that includes a function to find the container with the most water and logs the maximum amount of water. 37 | 4. **3Sum Script:** Create a script that includes a function to find all unique triplets in an array that sum to zero and logs the triplets. 38 | 5. **Group Anagrams Script:** Write a script that includes a function to group anagrams and logs the grouped anagrams. 39 | 40 | ## Achievement Unlocked 🏆 41 | 42 | By the end of these activities, you will: 43 | 44 | - ✅ Solve common medium-level LeetCode problems. 45 | - ✅ Apply advanced problem-solving skills to implement algorithms. 46 | - ✅ Understand and handle edge cases in more complex algorithmic solutions. 47 | - ✅ Gain confidence in solving medium-level coding challenges on LeetCode. 48 | 49 | --- 50 | 51 | Happy Coding! 💻🔥 -------------------------------------------------------------------------------- /Day23/Task.md: -------------------------------------------------------------------------------- 1 | # Day 23: LeetCode Hard Problems 💪 2 | 3 | Welcome to Day 23! Today, we're diving into some of the most challenging problems on LeetCode. These tasks will test your algorithmic skills and help you become proficient in solving complex problems. Let's conquer these challenges! 🌟 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Median of Two Sorted Arrays 📊 8 | - [X] **Task 1:** Solve the "Median of Two Sorted Arrays" problem on LeetCode. 9 | - Write a function that takes two sorted arrays of integers and returns the median of the two sorted arrays. 10 | - Log the median for a few test cases, including edge cases. 11 | 12 | ### Activity 2: Merge k Sorted Lists 🔗 13 | - [X] **Task 2:** Solve the "Merge k Sorted Lists" problem on LeetCode. 14 | - Write a function that takes an array of k linked lists, each sorted in ascending order, and merges them into one sorted linked list. 15 | - Create a few test cases with linked lists and log the merged list. 16 | 17 | ### Activity 3: Trapping Rain Water 🌧️ 18 | - [X] **Task 3:** Solve the "Trapping Rain Water" problem on LeetCode. 19 | - Write a function that takes an array of non-negative integers representing an elevation map, where the width of each bar is 1, and computes how much water it can trap after raining. 20 | - Log the amount of trapped water for a few test cases. 21 | 22 | ### Activity 4: N-Queens ♟️ 23 | - [X] **Task 4:** Solve the "N-Queens" problem on LeetCode. 24 | - Write a function that places n queens on an n x n chessboard such that no two queens attack each other, and returns all distinct solutions to the n-queens puzzle. 25 | - Log the distinct solutions for a few test cases. 26 | 27 | ### Activity 5: Word Ladder 🪜 28 | - [X] **Task 5:** Solve the "Word Ladder" problem on LeetCode. 29 | - Write a function that takes a begin word, an end word, and a dictionary of words, and finds the length of the shortest transformation sequence from the begin word to the end word. Each transformation can only change one letter, and each transformed word must exist in the word list. 30 | - Log the length of the shortest transformation sequence for a few test cases. 31 | 32 | ## Feature Request 🎯 33 | 34 | 1. **Median of Two Sorted Arrays Script:** Write a script that includes a function to find the median of two sorted arrays and logs the median. 35 | 2. **Merge k Sorted Lists Script:** Create a script that includes a function to merge k sorted linked lists and logs the merged list. 36 | 3. **Trapping Rain Water Script:** Write a script that includes a function to calculate the amount of trapped rainwater and logs the result. 37 | 4. **N-Queens Script:** Create a script that includes a function to solve the N-Queens problem and logs the distinct solutions. 38 | 5. **Word Ladder Script:** Write a script that includes a function to find the shortest transformation sequence in a word ladder and logs the sequence length. 39 | 40 | ## Achievement Unlocked 🏆 41 | 42 | By the end of these activities, you will: 43 | 44 | - ✅ Solve complex LeetCode problems. 45 | - ✅ Apply advanced problem-solving skills to implement efficient algorithms. 46 | - ✅ Understand and handle edge cases in hard algorithmic solutions. 47 | - ✅ Gain confidence in solving hard-level coding challenges on LeetCode. 48 | 49 | --- 50 | 51 | Time to tackle these hard problems and elevate your coding expertise! 💻🔥 -------------------------------------------------------------------------------- /Day24/README.md: -------------------------------------------------------------------------------- 1 | # Weather App 2 | 3 | The weather app called **Weather in** designed with HTML, CSS, Bootstrap and Javascript for educational purposes. That's all you need to know. 4 | 5 | ![weather app js](https://user-images.githubusercontent.com/65046391/82387841-fa32e000-9a2f-11ea-9bce-2a857bce5247.jpg) 6 | -------------------------------------------------------------------------------- /Day24/Task.md: -------------------------------------------------------------------------------- 1 | # Day 24: Project 1 - Weather App ☀️🌧️ 2 | 3 | Welcome to your first project! Today, you'll be building a dynamic Weather App that fetches real-time weather data, displays a 5-day forecast, and provides an interactive user experience. Let's get started! 🚀 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Setting Up the Project 🛠️ 8 | - [X] **Task 1:** Initialize a new project directory and set up the basic HTML structure for the weather app. 9 | - [X] **Task 2:** Add a basic CSS file to style the weather app, including a container for displaying weather information. 10 | 11 | ### Activity 2: Fetching Weather Data 🌍 12 | - [X] **Task 3:** Use the Fetch API to get current weather data from a public weather API (e.g., OpenWeatherMap). Log the response data to the console. 13 | - [X] **Task 4:** Parse the weather data and display the current temperature, weather condition, and city name on the web page. 14 | 15 | ### Activity 3: Adding Search Functionality 🔍 16 | - [X] **Task 5:** Add an input field and a search button to the HTML structure. Style the input and button using CSS. 17 | - [X] **Task 6:** Write a function to fetch and display weather data for a city entered in the search input field. Log any errors to the console. 18 | 19 | ### Activity 4: Displaying the Forecast 📅 20 | - [X] **Task 7:** Use the Fetch API to get the weather forecast from the public weather API. Log the response data to the console. 21 | - [X] **Task 8:** Parse the forecast data and display the temperature and weather condition for each day in the forecast on the web page. 22 | 23 | ### Activity 5: Enhancing the UI 🎨 24 | - [X] **Task 9:** Add icons or images to represent different weather conditions (e.g., sunny, rainy, cloudy) based on the weather data. 25 | - [X] **Task 10:** Add CSS animations or transitions to make the weather app more interactive and visually appealing. 26 | 27 | ## Feature Request 🎯 28 | 29 | 1. **Weather Data Fetching Script:** Write a script that fetches current weather data from a public API and displays the temperature, weather condition, and city name on the web page. 30 | 2. **Search Functionality Script:** Create a script that allows users to search for weather information by city name and displays the results. 31 | 3. **5-Day Forecast Script:** Write a script that fetches and displays a 5-day weather forecast on the web page. 32 | 4. **UI Enhancement Script:** Create a script that adds icons for different weather conditions and includes CSS animations or transitions for a better user experience. 33 | 34 | ## Achievement Unlocked 🏆 35 | 36 | By the end of these activities, you will: 37 | 38 | - ✅ Set up a basic project structure with HTML and CSS. 39 | - ✅ Use the Fetch API to retrieve and display weather data from a public API. 40 | - ✅ Implement search functionality to fetch weather data for different cities. 41 | - ✅ Display a 5-day weather forecast using data from a public API. 42 | - ✅ Enhance the user interface with icons and animations to make the weather app more interactive and visually appealing. 43 | 44 | --- 45 | 46 | Let's build a weather app that not only informs but also delights users with its functionality and design! 🌤️💻 -------------------------------------------------------------------------------- /Day24/img/cloud.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Day24/img/day_image.svg: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /Day24/img/down.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Day24/img/night_image.svg: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /Day24/img/up.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Day24/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Weather in App 7 | 13 | 14 | 15 | 16 |
17 |

Weather in

18 |
19 | 26 |
27 | 28 |
29 |
30 |
31 |

Abuja

32 | ... 33 |
34 | 35 |
36 | 37 |
38 |
39 |
40 | 30°C 41 |
42 |
43 |

Thunder Storm

44 |

30°C

45 |

27°C

46 |
47 |
48 | 49 |
50 | 51 |
52 |
53 |
54 |

30°C

55 | Feels Like 56 |
57 |
58 |

55%

59 | Humidity 60 |
61 |
62 |
63 |
64 |
65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /Day24/index.js: -------------------------------------------------------------------------------- 1 | const searchForm = document.querySelector('.search-loaction'); 2 | const cityValue = document.querySelector('.search-loaction input'); 3 | const cityName = document.querySelector('.city-name p'); 4 | const cardBody = document.querySelector('.card-body'); 5 | const timeImage = document.querySelector('.card-top img'); 6 | const cardInfo = document.querySelector('.back-card'); 7 | 8 | const spitOutCelcius = (kelvin) => { 9 | celcius = Math.round(kelvin - 273.15); 10 | return celcius; 11 | } 12 | const isDayTime = (icon) => { 13 | if (icon.includes('d')) { return true } 14 | else { return false } 15 | } 16 | updateWeatherApp = (city) => { 17 | console.log(city); 18 | const imageName = city.weather[0].icon; 19 | const iconSrc = `http://openweathermap.org/img/wn/${imageName}@2x.png` 20 | cityName.textContent = city.name; 21 | cardBody.innerHTML = ` 22 |
23 |
24 | ${spitOutCelcius(city.main.temp)}°C 25 |
26 |
27 |

${city.weather[0].description}

28 |

${spitOutCelcius(city.main.temp_max)}°C

29 |

${spitOutCelcius(city.main.temp_min)}°C

30 |
31 |
32 | 33 |
34 | 35 |
36 |
37 |
38 |

${spitOutCelcius(city.main.feels_like)}°C

39 | Feels Like 40 |
41 |
42 |

${city.main.humidity}%

43 | Humidity 44 |
45 |
46 | `; 47 | if (isDayTime(imageName)) { 48 | console.log('day'); 49 | timeImage.setAttribute('src', 'img/day_image.svg'); 50 | if (cityName.classList.contains('text-white')) { 51 | cityName.classList.remove('text-white'); 52 | } else { 53 | cityName.classList.add('text-black'); 54 | } 55 | 56 | } else { 57 | console.log('night'); 58 | timeImage.setAttribute('src', 'img/night_image.svg'); 59 | if (cityName.classList.contains('text-black')) { 60 | cityName.classList.remove('text-black'); 61 | } else { 62 | cityName.classList.add('text-white'); 63 | } 64 | 65 | } 66 | 67 | cardInfo.classList.remove('d-none'); 68 | } 69 | 70 | 71 | 72 | //add an event listner to the form 73 | searchForm.addEventListener('submit', e => { 74 | e.preventDefault(); 75 | const citySearched = cityValue.value.trim(); 76 | console.log(citySearched); 77 | searchForm.reset(); 78 | 79 | requestCity(citySearched) 80 | .then((data) => { 81 | updateWeatherApp(data); 82 | }) 83 | .catch((error) => { console.log(error) }); 84 | }) -------------------------------------------------------------------------------- /Day24/request.js: -------------------------------------------------------------------------------- 1 | const key = 'cbe3dd267a18f6c89943b3eff94f1ed7'; 2 | 3 | const requestCity = async (city) => { 4 | const baseURL = 'http://api.openweathermap.org/data/2.5/weather' 5 | const query = `?q=${city}&appid=${key}`; 6 | 7 | //make fetch call (promise call) 8 | const response = await fetch(baseURL + query); 9 | 10 | const data = await response.json(); 11 | return data; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Day24/style.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Raleway:wght@100;400;700&display=swap'); 2 | 3 | body { 4 | font-family: 'Raleway', sans-serif; 5 | background: #e0e0e0; 6 | color: #707070; 7 | margin: 0; 8 | padding: 0; 9 | } 10 | 11 | .container { 12 | max-width: 400px; 13 | min-width: 400px; 14 | } 15 | 16 | .title { 17 | font-weight: 700; 18 | font-size: 50px; 19 | } 20 | 21 | .form-rounded { 22 | border-radius: 2em; 23 | } 24 | 25 | .back-card { 26 | border-radius: 40px !important; 27 | } 28 | 29 | .city-name { 30 | position: absolute; 31 | width: 100%; 32 | } 33 | 34 | .city-name p { 35 | font-size: 16pt; 36 | font-weight: 400; 37 | } 38 | 39 | .city-name span { 40 | font-weight: 400; 41 | font-size: 36pt; 42 | font-family: 'Times New Roman', Times, serif; 43 | position: relative; 44 | top: -60px; 45 | } 46 | 47 | .temp span { 48 | font-weight: 100; 49 | font-size: 5em; 50 | letter-spacing: -5px; 51 | white-space: nowrap; 52 | } 53 | .card-mid { 54 | line-height: 0.5; 55 | } 56 | 57 | .condition { 58 | line-height: 1em; 59 | font-weight: 700; 60 | font-size: 1em; 61 | text-transform: capitalize; 62 | } 63 | .high::before { 64 | content: ''; 65 | background: url('img/up.svg') no-repeat; 66 | width: 10px; 67 | height: 15px; 68 | display: inline-block; 69 | position: relative; 70 | top: 3px; 71 | } 72 | 73 | .low::before { 74 | content: ''; 75 | background: url('img/down.svg') no-repeat; 76 | width: 10px; 77 | height: 15px; 78 | display: inline-block; 79 | position: relative; 80 | top: 3px; 81 | } 82 | .icon-container { 83 | border-radius: 100%; 84 | width: 100px; 85 | height: 100px; 86 | background: #202020; 87 | } 88 | .icon-container img { 89 | margin: auto; 90 | } 91 | 92 | .card-bottom { 93 | line-height: 0.5; 94 | } 95 | .card-bottom span { 96 | font-size: 12px; 97 | } 98 | .card-bottom p { 99 | font-size: 50px; 100 | font-weight: 100; 101 | letter-spacing: -2px; 102 | } 103 | -------------------------------------------------------------------------------- /Day25/Task.md: -------------------------------------------------------------------------------- 1 | # Day 25: Project 2 - Movie Search App 🎬🎥 2 | 3 | Ready to dive into your second project? Today, you'll be building a Movie Search App that fetches movie data from a public API, displays search results, and allows users to explore detailed information about their favorite films. Let's get rolling! 🍿🎉 4 | 5 | ## Tasks/Activities 📝 6 | 7 | ### Activity 1: Setting Up the Project 🛠️ 8 | - [ ] **Task 1:** Initialize a new project directory and set up the basic HTML structure for the movie search app. 9 | - [ ] **Task 2:** Add a basic CSS file to style the movie search app, including a container for displaying movie search results. 10 | 11 | ### Activity 2: Fetching Movie Data 🌐 12 | - [ ] **Task 3:** Use the Fetch API to get movie data from a public movie API (e.g., OMDB API or The Movie Database API). Log the response data to the console. 13 | - [ ] **Task 4:** Parse the movie data and display the movie title, poster, and release year on the web page. 14 | 15 | ### Activity 3: Adding Search Functionality 🔍 16 | - [ ] **Task 5:** Add an input field and a search button to the HTML structure. Style the input and button using CSS. 17 | - [ ] **Task 6:** Write a function to fetch and display movie data based on a search query entered in the input field. Log any errors to the console. 18 | 19 | ### Activity 4: Displaying Detailed Movie Information 📜 20 | - [ ] **Task 7:** Modify the search results to include a "More Info" button for each movie. When clicked, fetch and display additional details about the movie, such as the plot, director, and actors. 21 | - [ ] **Task 8:** Create a modal or a new section on the page to display the detailed movie information. 22 | 23 | ### Activity 5: Enhancing the UI 🎨 24 | - [ ] **Task 9:** Add CSS styles to improve the layout and design of the search results and detailed movie information. 25 | - [ ] **Task 10:** Add CSS animations or transitions to make the movie search app more interactive and visually appealing. 26 | 27 | ## Feature Request 🎯 28 | 29 | 1. **Movie Data Fetching Script:** Write a script that fetches movie data from a public API and displays the title, poster, and release year on the web page. 30 | 2. **Search Functionality Script:** Create a script that allows users to search for movies by title and displays the search results. 31 | 3. **Detailed Information Script:** Write a script that fetches and displays additional details about a selected movie, such as the plot, director, and actors. 32 | 4. **UI Enhancement Script:** Create a script that improves the layout and design of the movie search app with CSS styles and animations. 33 | 34 | ## Achievement Unlocked 🏆 35 | 36 | By the end of these activities, you will: 37 | 38 | - ✅ Set up a basic project structure with HTML and CSS. 39 | - ✅ Use the Fetch API to retrieve and display movie data from a public API. 40 | - ✅ Implement search functionality to fetch and display movie data based on user input. 41 | - ✅ Fetch and display detailed information about selected movies. 42 | - ✅ Enhance the user interface with CSS styles and animations to make the movie search app more interactive and visually appealing. 43 | 44 | --- 45 | 46 | happy Coding! 🎬💻 -------------------------------------------------------------------------------- /Day25/images/screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashksaini-coder/Javascript-30Days/7eb7728f64730f08a799a566ead281758ac05413/Day25/images/screenshot-1.png -------------------------------------------------------------------------------- /Day25/images/screenshot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashksaini-coder/Javascript-30Days/7eb7728f64730f08a799a566ead281758ac05413/Day25/images/screenshot-2.png -------------------------------------------------------------------------------- /Day25/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Movie Info 8 | 12 | 13 | 14 | 15 | 16 | 23 |
24 |
25 |

Search For Any Movie

26 |
27 |
28 |
29 |
🔍
30 |
31 | 37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Day25/main.js: -------------------------------------------------------------------------------- 1 | $(document).ready(() => { 2 | $("#searchForm").on("submit", (event) => { 3 | let searchText = $("#searchText").val(); 4 | getMovies(searchText); 5 | event.preventDefault(); 6 | }); 7 | }); 8 | 9 | function getMovies(searchText) { 10 | axios 11 | .get(`http://www.omdbapi.com/?i=tt3896198&apikey=3a43dcb5&s=${searchText}`) 12 | .then((response) => { 13 | let movies = response.data.Search; 14 | let output = ""; 15 | $.each(movies, (index, movie) => { 16 | output += ` 17 |
18 |
19 | 20 |
${movie.Title}
21 | Movie Details 22 |
23 |
`; 24 | }); 25 | $("#movies").html(output); 26 | }) 27 | .catch((error) => { 28 | console.log(error); 29 | }); 30 | } 31 | 32 | function movieSelected(id) { 33 | sessionStorage.setItem("movieId", id); 34 | window.location = "movie.html"; 35 | return false; 36 | } 37 | 38 | function getMovie() { 39 | let movieId = sessionStorage.getItem("movieId"); 40 | 41 | axios 42 | .get(`http://www.omdbapi.com/?i=${movieId}&apikey=3a43dcb5`) 43 | .then((response) => { 44 | let movie = response.data; 45 | 46 | let output = ` 47 |
48 |
49 | 50 |
51 |
52 |

${movie.Title}

53 |
    54 |
  • Genre: ${movie.Genre}
  • 55 |
  • Released: ${movie.Released}
  • 56 |
  • Rated: ${movie.Rated}
  • 57 |
  • IMDB Rating: ${movie.imdbRating}
  • 58 |
  • Director: ${movie.Director}
  • 59 |
  • Writer: ${movie.Writer}
  • 60 |
  • Actors: ${movie.Actors}
  • 61 |
  • 62 |
63 |
64 |
65 |
66 |
67 |

Plot

68 | ${movie.Plot} 69 |
70 | View IMDB 71 | Go Back To Search 72 |
73 |
74 | `; 75 | 76 | $("#movie").html(output); 77 | }) 78 | .catch((err) => { 79 | console.log(err); 80 | }); 81 | } 82 | -------------------------------------------------------------------------------- /Day25/movie.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Movie Info 8 | 12 | 13 | 14 | 15 | 16 | 23 | 24 |
25 |
26 |
27 | 28 | 29 | 30 | 31 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Day25/style.css: -------------------------------------------------------------------------------- 1 | #movies img, 2 | #movie img { 3 | width: 100%; 4 | } 5 | 6 | @media (min-width: 960px) { 7 | #movies .col-md-3 .card { 8 | height: 390px; 9 | } 10 | 11 | #movies .col-md-3 img { 12 | height: 290px; 13 | } 14 | } 15 | 16 | html { 17 | --s: 94px; /* control the size*/ 18 | --c1: #384670; 19 | --c2: #d86e4b; 20 | 21 | --g:var(--c1) 0 25%,var(--c2) 0 50%,#0000 0; 22 | background: 23 | conic-gradient(from 135deg at 25% 75%, var(--g)) 24 | calc(var(--s)/4) calc(var(--s)/-4), 25 | conic-gradient(from -45deg at 75% 25%, var(--g)) 26 | calc(var(--s)/-4) calc(var(--s)/4), 27 | repeating-conic-gradient(var(--g)); 28 | background-size: var(--s) var(--s); 29 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Yash Kumar Saini 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | Javascript-30Days 3 |
4 |
5 | 6 | ### Welcome to the 30 Days of JavaScript Challenge! This repository contains projects created during the challenge. 7 | 8 | ## Contribution Guide 9 | 10 | We welcome contributions from the community! If you would like to contribute to this project, please follow these steps: 11 | 12 | 1. Fork the repository. 13 | 2. Create a new branch for your contribution. 14 | 3. Make your changes and commit them. 15 | 4. Push your branch to your forked repository. 16 | 5. Open a pull request to merge your changes into the main repository. 17 | 18 | ## Usage Guide 19 | 20 | To use the projects in this repository, follow these steps: 21 | 22 | 1. Clone the repository to your local machine. 23 | 2. Navigate to the project folder you want to use. 24 | 3. Follow the instructions provided in each Day Task README file. 25 | 26 | ## Author 27 | 28 | [![Author](https://img.shields.io/badge/Author-Yash_Kumar_Saini-blue)](https://github.com/yashksaini-coder) 29 | 30 | --------------------------------------------------------------------------------