├── challanges1-to-72 ├── problem41 │ ├── problem.md │ └── problem41.js ├── problem42 │ ├── problem.md │ └── problem42.js ├── problem38 │ ├── problem.md │ └── problem38.js ├── problem64 │ ├── problme.md │ └── problem64.js ├── problem63 │ ├── problem.md │ └── problem63.js ├── problem25 │ ├── problem.md │ └── problem25.js ├── problem13 │ ├── problem.md │ └── problem13.js ├── problem3 │ ├── problem3.js │ └── problme.md ├── problem36 │ ├── problem.md │ └── problem36.js ├── problem35 │ ├── problem.md │ └── problem35.js ├── problem4 │ ├── problem4.js │ └── problem.md ├── problem62 │ ├── problem.md │ └── problem62.js ├── problem33 │ ├── problem.md │ └── problem33.js ├── problem26 │ ├── problem.md │ └── problem26.js ├── problem14 │ ├── problem.md │ └── problme14.js ├── problem19 │ ├── problem.md │ └── problem19.js ├── problme72 │ ├── problem.md │ └── problme72.js ├── problem17 │ ├── problem.md │ └── problem17.js ├── problem27 │ ├── problem.md │ └── problem27.js ├── problem69 │ ├── problme.md │ └── problme69.js ├── problem1 │ ├── problem1.js │ └── problem.md ├── problem66 │ ├── problem.md │ └── problme66.js ├── problem71 │ ├── problem.md │ └── problem71.js ├── problem24 │ ├── problem.md │ └── problem24.js ├── problem70 │ ├── problme.md │ └── problme70.js ├── problem9 │ ├── problem.md │ └── problem9.js ├── problem12 │ ├── problem.md │ └── problem12.js ├── problem67 │ ├── problme.md │ └── problem67.js ├── problem46 │ ├── problem.md │ └── problem46.js ├── problem20 │ ├── problem.md │ └── problem20.js ├── problem65 │ ├── problem.md │ └── problme65.js ├── problem31 │ ├── problem.md │ └── problem31.js ├── problem32 │ ├── problem.md │ └── problem32.js ├── problem34 │ ├── problem.md │ └── problem34.js ├── problem10 │ ├── problem.md │ └── problem10.js ├── problem15 │ ├── problem.md │ └── problem15.js ├── problem49 │ ├── problem.md │ └── problem49.js ├── problem51 │ ├── problem.md │ └── problem51.js ├── problem54 │ ├── problem.md │ └── problem54.js ├── problem7 │ ├── problem.md │ └── proble7.js ├── problem16 │ ├── problem.md │ └── problem16.js ├── problem45 │ ├── problem.md │ └── problem45.js ├── problem52 │ ├── problem52.md │ └── problem52.js ├── problem29 │ ├── problem.md │ └── problem29.js ├── problem30 │ ├── problem.md │ └── problem30.js ├── problem22 │ ├── problem.md │ └── problem22.js ├── problem68 │ ├── problme.md │ └── problem68.js ├── problem18 │ ├── problem.md │ └── problem18.js ├── problem37 │ ├── problem.md │ └── problem37.js ├── problem47 │ ├── problem.md │ └── problem47.js ├── problem2 │ ├── problem2.js │ └── problem.md ├── problem11 │ ├── problem.md │ └── problem11.js ├── problem6 │ ├── problem.md │ └── problem6.js ├── problem28 │ ├── problem.md │ └── problem28.js ├── problem40 │ ├── problem.md │ └── problem40.js ├── problem43 │ ├── problem.md │ └── proble43.js ├── problem8 │ ├── problem.md │ └── problem8.js ├── problem23 │ ├── problem.md │ └── problem23.js ├── problem21 │ ├── problem.md │ └── problem21.js ├── problem58 │ ├── problem.md │ └── problem58.js ├── problem61 │ ├── problem.md │ └── problem61.js ├── problem57 │ ├── problem.md │ └── problem57.js ├── problem44 │ ├── problem.md │ └── problem44.js ├── problem50 │ ├── problem.md │ └── problem50.js ├── problem39 │ ├── problem.md │ └── problem39.js ├── problem60 │ ├── problem.md │ └── problem60.js ├── problem5 │ ├── problem.md │ └── problem5.js ├── problem59 │ ├── problem.md │ └── problem59.js ├── problem55 │ ├── problem.md │ └── problem55.js ├── problem56 │ ├── problem.md │ └── problem56.js ├── problem48 │ ├── problem.md │ └── problem48.js └── problem53 │ ├── problem53.md │ └── problem53.js ├── .vscode ├── settings.json └── launch.json ├── LeetCode └── 30daysJavaScript │ ├── 3.To_Be_or_Not_To_Be │ └── To_Be_or_Not_To_Be.js │ ├── 13.Sleep │ └── sleep.ts │ ├── 9.Return_Length_of_Arguments_Passed │ └── Return_Length_of_Arguments_Passed.ts │ ├── 1.Create-Hello-World-Function │ └── problem.js │ ├── 2.Counter │ └── Counter.js │ ├── 12.Add_Two_Promises │ └── Add_Two_Promises.ts │ ├── 5.Apply_Transform_Over_Each_Element_in_Array │ └── arrayTransform.ts │ ├── 8.Function_Composition │ └── Function_Composition.ts │ ├── 6.Filter_Elements_from_Array │ └── Filter_Elements_from_Array.ts │ ├── 4.Counter-II │ └── CounterII.ts │ ├── 10.Allow_One_Function_Call │ └── Allow_One_Function_Call.ts │ ├── 7.Array_Reduce_Transformation │ └── Array_Reduce_Transformation.ts │ ├── 17.Cache_with_Time_Limit │ └── Cache_with_Time_Limit.ts │ ├── 14.Timeout_Cancellation │ └── Timeout_Cancellation.ts │ ├── 16.Promise_Time_Limite │ └── Promise_Time_Limite.ts │ ├── 11.Memoize │ └── Memoize.ts │ └── 15.Interval_Cancellation │ └── Interval_Cancellation.ts └── README.md /challanges1-to-72/problem41/problem.md: -------------------------------------------------------------------------------- 1 | ## Find the expensive product -------------------------------------------------------------------------------- /challanges1-to-72/problem42/problem.md: -------------------------------------------------------------------------------- 1 | ## Find the lowest price product -------------------------------------------------------------------------------- /challanges1-to-72/problem38/problem.md: -------------------------------------------------------------------------------- 1 | Calculate the average rate of profit -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cSpell.words": [ 3 | "biryani" 4 | ] 5 | } -------------------------------------------------------------------------------- /challanges1-to-72/problem64/problme.md: -------------------------------------------------------------------------------- 1 | 2 | ## Problem 64: 3 | 4 | ### Explain what a callback function is and provide a simple example? -------------------------------------------------------------------------------- /challanges1-to-72/problem63/problem.md: -------------------------------------------------------------------------------- 1 | ## Problem 63: 2 | 3 | ### Write a code to calculate if the string is palindrome ? (Use javascript only) -------------------------------------------------------------------------------- /challanges1-to-72/problem25/problem.md: -------------------------------------------------------------------------------- 1 | 2 | Write a function called make_avg() which will take an three integers and return the average of those values. 3 | -------------------------------------------------------------------------------- /challanges1-to-72/problem13/problem.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | আসকে আমার মন ভালো নেই এই কথা ৩৯ বার আউটপুট হিসেবে দেখাও। 4 | 5 | `আসকে আমার মন ভালো নেই` show this text 39 times -------------------------------------------------------------------------------- /challanges1-to-72/problem3/problem3.js: -------------------------------------------------------------------------------- 1 | 2 | var text1 = "I am going to be"; 3 | var text2 = "an awesome web developer"; 4 | 5 | console.log(text1 + " " + text2); -------------------------------------------------------------------------------- /challanges1-to-72/problem36/problem.md: -------------------------------------------------------------------------------- 1 | কেউ ১০০ এর মধ্যে কত মার্ক্স্ পেয়েছে সেটা তোমাকে বলে দিবে। তুমি একটা ফাংশন দিয়ে বলে দিবে সে এ+ পাবে নাকি অন্য কোন গ্রেড পাবে। -------------------------------------------------------------------------------- /challanges1-to-72/problem35/problem.md: -------------------------------------------------------------------------------- 1 | You will be given the function input as Fahrenheit. You calculate the temperature and convert it to Celsius and return the output -------------------------------------------------------------------------------- /challanges1-to-72/problem4/problem4.js: -------------------------------------------------------------------------------- 1 | 2 | var sharahsNum = 119 ; 3 | var haveToDivideWith = 5 ; 4 | 5 | var remiderOfTheNum = 119 % 5 ; 6 | 7 | console.log(remiderOfTheNum); -------------------------------------------------------------------------------- /challanges1-to-72/problem62/problem.md: -------------------------------------------------------------------------------- 1 | ## Problem 62: 2 | 3 | 4 | ### Write a code on how to calculate the number of vowels and consonants in a string?(Use Javascript only) 5 | -------------------------------------------------------------------------------- /challanges1-to-72/problem33/problem.md: -------------------------------------------------------------------------------- 1 | Write a function findOddSum() that will take the array [5, 7, 8, 10, 45, 30] 2 | as the input parameter and will return the sum of the odd numbers. -------------------------------------------------------------------------------- /challanges1-to-72/problem26/problem.md: -------------------------------------------------------------------------------- 1 | Challenging: Write a function called make_avg() which will take an array of integers and the size of that array and return the average of those values. -------------------------------------------------------------------------------- /challanges1-to-72/problem14/problem.md: -------------------------------------------------------------------------------- 1 | Task 1. Print the numbers 58 to 98 2 | 3 | Task 2. Print all the even numbers between 412 to 456 4 | 5 | Task 3. Print all the odd numbers between 581 to 623 -------------------------------------------------------------------------------- /challanges1-to-72/problem19/problem.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | Task:Write a function that returns the multiplication table of 13 as output. 4 | 5 | একটা ফাংশন লিখবা যেটা ১৩ এর নামতা (multiplication table) আউটপুট হিসেবে দেখাবে। -------------------------------------------------------------------------------- /challanges1-to-72/problme72/problem.md: -------------------------------------------------------------------------------- 1 | ## Problem 72: 2 | 3 | ### Implement a JavaScript function to find the second smallest element in an array of numbers. The function should return the second smallest number. 4 | 5 | -------------------------------------------------------------------------------- /challanges1-to-72/problem17/problem.md: -------------------------------------------------------------------------------- 1 | Run a for loop. 30 to 86. And when this loop goes to 44, it will brake. Code that thing 2 | 3 | একটা ফর লুপ চালাও। ৩০ থেকে ৮৬ পর্যন্ত। আর এই লুপ ৪৪ এ গেলে ব্রেক করবে। সেই জিনিস কোড করে দেখাও -------------------------------------------------------------------------------- /challanges1-to-72/problem27/problem.md: -------------------------------------------------------------------------------- 1 | Write a function called odd_even() which takes an integer value and tells whether this value is even or odd. You need to do it in 4 ways: 2 | Has return+ Has parameter 3 | No return+Has parameter -------------------------------------------------------------------------------- /challanges1-to-72/problem69/problme.md: -------------------------------------------------------------------------------- 1 | ## Problem 69: 2 | 3 | ### Implement a simple JavaScript calculator. The calculator should take two numbers and an operator (+, -, *, /) as input and return the result of the operation. 4 | 5 | -------------------------------------------------------------------------------- /challanges1-to-72/problem1/problem1.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var momGave = 1000 ; 4 | var applePerKG = 300; 5 | var orangePerKG = 400; 6 | var totalCost = applePerKG + orangePerKG; 7 | 8 | 9 | console.log( momGave - totalCost); 10 | 11 | // Done -------------------------------------------------------------------------------- /challanges1-to-72/problem66/problem.md: -------------------------------------------------------------------------------- 1 | ## Problem 66: 2 | 3 | ### Create a function that takes an array of numbers as input and returns the sum of all positive numbers in the array. 4 | 5 | **Example `Input: [2, -5, 10, -3, 7]` Example` Output: 19`** -------------------------------------------------------------------------------- /challanges1-to-72/problem71/problem.md: -------------------------------------------------------------------------------- 1 | ## Problem 71: 2 | 3 | ### Implement a function that converts a Roman numeral to an integer. The function should take a Roman numeral string (e.g., "IX" or "XXI") as input and return the corresponding integer value. -------------------------------------------------------------------------------- /challanges1-to-72/problem24/problem.md: -------------------------------------------------------------------------------- 1 | Write a function called foo() which prints "foo" and a function called bar() which prints "bar". Call function bar() in the foo() function after printing. What will be the output? Now call the foo() to see the output. 2 | -------------------------------------------------------------------------------- /challanges1-to-72/problem70/problme.md: -------------------------------------------------------------------------------- 1 | 2 | ## Problem 70: 3 | 4 | ### Create a program that generates a random password of a specified length. The password should include a mix of uppercase letters, lowercase letters, numbers, and special characters. 5 | 6 | -------------------------------------------------------------------------------- /challanges1-to-72/problem9/problem.md: -------------------------------------------------------------------------------- 1 | You are given three numbers 13, 79, and 45. Write a program that will print the 2 | largest number using if-else. 3 | 4 | 5 | [View problem source 📤](https://drive.google.com/file/d/1bfxye7A1p-BBJCQCXaiUetl_qyS2Vc1E/view) -------------------------------------------------------------------------------- /challanges1-to-72/problem12/problem.md: -------------------------------------------------------------------------------- 1 | ২৪. তোমার কাছে: ৮০০০০ টাকার বেশি হলে তুমি mac কিনবে, ৬০ টাকার বেশি হলে gaming ল্যাপটপ কিনবে, ৪০ হাজার টাকার বেশি হলে lenovo yoga কম্পিউটার কিনবে , ২০ হাজার টাকার বেশি হলে পুরান ল্যাপটপ কিনবে। না হয় তুমি মোবাইল দিয়ে কাজ চালাবে। -------------------------------------------------------------------------------- /challanges1-to-72/problem13/problem13.js: -------------------------------------------------------------------------------- 1 | // `আসকে আমার মন ভালো নেই 😞😞` show this text 39 times 2 | 3 | 4 | // Using while loop 5 | 6 | var i = 1 ; 7 | 8 | while( i <= 39){ 9 | console.log(i + ". " + "আসকে আমার মন ভালো নেই 😞😞"); 10 | i++; 11 | } -------------------------------------------------------------------------------- /challanges1-to-72/problem67/problme.md: -------------------------------------------------------------------------------- 1 | ## Problem 67: 2 | 3 | ### Write a JavaScript program to find the most frequent element in an array and return it. 4 | 5 | **Example `Input: [3, 5, 2, 5, 3, 3, 1, 4, 5]` Example `Output: 3`** 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /challanges1-to-72/problem46/problem.md: -------------------------------------------------------------------------------- 1 | 2 | **Write an arrow function where it will do the following:** 3 | 4 | 1. Square each array element 5 | 2. Calculate the sum of the squared elements 6 | 3. Return the average of the sum of the squared elements 7 | 8 | **Print the result.** -------------------------------------------------------------------------------- /challanges1-to-72/problem20/problem.md: -------------------------------------------------------------------------------- 1 | 2 | একটা ফাংশন লিখ যেটা যেকোন নামকে uppercase বা রেগুলার কেইস হিসেবে নিবে আর আউটপুট হিসেবে সেই নাম lowercase করে রিটার্ন করবে। 3 | 4 | Write a function that takes any name as uppercase or regular case and returns the name as lowercase as output. -------------------------------------------------------------------------------- /challanges1-to-72/problem65/problem.md: -------------------------------------------------------------------------------- 1 | 2 | ## Problem 65: 3 | 4 | ### Create a function that takes a string as input and returns the reversed version of the string without using the built-in reverse() method. 5 | 6 | **Example `Input: "hello world"` Example `Output: "dlrow olleh"`** -------------------------------------------------------------------------------- /challanges1-to-72/problem17/problem17.js: -------------------------------------------------------------------------------- 1 | /* Run a for loop. 30 to 86. And when this loop goes to 44, it will brake. Code that thing */ 2 | 3 | 4 | for( var i = 30; i <= 86; i++){ 5 | 6 | if( i == 44){ 7 | break; 8 | } 9 | console.log(i); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /challanges1-to-72/problem31/problem.md: -------------------------------------------------------------------------------- 1 | এমন একটা ফ্যাংশনা লিখো যেটাকে তুমি ঘন্টাকে ইনপুট প্যারামিটার হিসেবে দিবে। আর সে সেই ঘন্টাকে মিনিটে কনভার্ট করে মিনিট রিটার্ন করবে। 2 | 3 | Write a function that takes the hour as an input parameter. And it will convert those hours to minutes and return minutes. -------------------------------------------------------------------------------- /challanges1-to-72/problem32/problem.md: -------------------------------------------------------------------------------- 1 | Write a function findLeapYear() that will take the array 2 | [2023,2024,2025,2028,2030] as the input parameter and will check if 3 | each year is a leap year. If a year is a leap year insert that year in a 4 | new array, return the new array and print the result. -------------------------------------------------------------------------------- /challanges1-to-72/problem34/problem.md: -------------------------------------------------------------------------------- 1 | তোমাকে ফাংশনের ইনপুট হিসেবে সেলসিয়াস দিবে। তুমি ক্যালকুলেশন করে তাপমাত্রা ফারেনহাইট এ কনভার্ট করে সেটার আউটপুট রিটার্ন করবে 2 | 3 | You will be given Celsius as input to the function. You calculate the temperature and convert it to Fahrenheit and return the output -------------------------------------------------------------------------------- /challanges1-to-72/problem10/problem.md: -------------------------------------------------------------------------------- 1 | You are given a triangle with the sides 9, 8, 9. Write a program to check whether a 2 | triangle is Isosceles or not using if-else. 3 | 4 | Isosceles => two sides are equal 5 | 6 | 7 | [View problem source 📤](https://drive.google.com/file/d/1bfxye7A1p-BBJCQCXaiUetl_qyS2Vc1E/view) -------------------------------------------------------------------------------- /challanges1-to-72/problem15/problem.md: -------------------------------------------------------------------------------- 1 | তুমি এতদিন যা যা জিনিস শিখছো সেগুলার নাম দিয়ে একটা array বানাও। তারপর একটা for লুপ দিয়ে সেই array এর সব উপাদান কে আউটপুট হিসেবে দেখাও। 2 | 3 | Create an array with the names of all the things you have learned in this lesson. Then use a for loop to output all elements of that array. -------------------------------------------------------------------------------- /challanges1-to-72/problem49/problem.md: -------------------------------------------------------------------------------- 1 | ## Practice Problem 49 **reduce()** 2 | 3 | You have **an array [ 1, 9, 17, 22 ].** Add the all elements 4 | of this array and give output. Do this using `for loop` & 5 | `array.reduce()` method. 6 | 7 | problem provider : https://drive.google.com/file/d/1XcvIBe_rJlr6GY2rTnHlbIluTABXNhp7/view -------------------------------------------------------------------------------- /challanges1-to-72/problem51/problem.md: -------------------------------------------------------------------------------- 1 | 2 | ## Practice Problem 51 `Access Object values` 3 | 4 | ``` 5 | const student = { 6 | name: 'Fredie', 7 | age: 26, 8 | } 9 | ``` 10 | 11 | ### Task: Console the value of `age` 12 | 13 | problem provider : https://drive.google.com/file/d/1XcvIBe_rJlr6GY2rTnHlbIluTABXNhp7/view -------------------------------------------------------------------------------- /challanges1-to-72/problem54/problem.md: -------------------------------------------------------------------------------- 1 | ## Practice 54: 2 | 3 | Create a function called `highestRunScorer` that will 4 | Receive a `2d array` called `playersInfo` 5 | Based on highest score, return the name of the player 6 | 7 | > Things required 8 | 9 | - Variable 10 | - If-else 11 | - Loop 12 | - Function 13 | - Array 14 | 15 | 16 | -------------------------------------------------------------------------------- /challanges1-to-72/problem7/problem.md: -------------------------------------------------------------------------------- 1 | You are given an array: 2 | 3 | var fruits = ['Apple', 'Banana', 'Orange']; 4 | 5 | a) Find the index of ‘Banana’ and replace ‘Banana’ with ‘Mango’. 6 | b) Remove ‘Orange’ and add ‘Watermelon’. 7 | 8 | 9 | 10 | [View problem source 📤](https://drive.google.com/file/d/1bfxye7A1p-BBJCQCXaiUetl_qyS2Vc1E/view) -------------------------------------------------------------------------------- /challanges1-to-72/problem16/problem.md: -------------------------------------------------------------------------------- 1 | 2 | তুমি এতদিন পর্যন্ত যে যে মডেলের মোবাইল ফোন ইউজ করেছো সেগুলার নাম দিয়ে একটা array বানাও। তারপর একটা while লুপ দিয়ে সেই array এর উপাদান গুলা একটা একটা করে আউটপুট হিসেবে দেখাও 3 | 4 | 5 | Create an array with the names of all the mobile phone models you have used so far. Then show the elements of that array as output one by one with a while loop -------------------------------------------------------------------------------- /challanges1-to-72/problem45/problem.md: -------------------------------------------------------------------------------- 1 | 2 | ## Practice Problem 45 3 | 4 | **Write an arrow function where it will do the following:** 5 | 6 | 1. It will take an array where the array elements will be the 7 | name of your friends 8 | 9 | 2. Check if the length of each element is even, push elements 10 | with even length to a new array and return the result 11 | Print the result. -------------------------------------------------------------------------------- /challanges1-to-72/problem52/problem52.md: -------------------------------------------------------------------------------- 1 | ## Practice Problem 52: `Access Object values` 2 | 3 | 4 | ``` 5 | let data = { 6 | location:[ 7 | { 8 | latitude: '34.5, 37.8', 9 | longitude:'98.77, 58.7', 10 | city: 'Hyderabad', 11 | country: 'India', 12 | } 13 | ] 14 | }; 15 | ``` 16 | ### Console the value of `city` -------------------------------------------------------------------------------- /challanges1-to-72/problem29/problem.md: -------------------------------------------------------------------------------- 1 | leapYear() নামে ফাংশন লিখো এবং নেক্সট ইয়ার অর্থাৎ ২০২৩ কি leap year নাকি সেটা চেক করো। Leap year হলে ফাংশন true রিটার্ন করবে আর leap year না হলে false রিটার্ন করবে। 2 | 3 | 4 | Write a function called leapYear() and check whether the next year i.e. 2023 is a leap year or not. The function will return true if it is a leap year and false if it is not a leap year. -------------------------------------------------------------------------------- /challanges1-to-72/problem30/problem.md: -------------------------------------------------------------------------------- 1 | তোমার বয়স কি odd নাকি even সংখ্যা সেটা চেক কর একটা ফাংশন দিয়ে। সেই ফাংশনকে কোন সংখ্যা প্যারামিটার হিসেবে দিলে, সেই সংখ্যা Even হলে ফাংশন true রিটার্ন করবে আর Odd হলে false রিটার্ন করবে। 2 | 3 | Check whether your age is odd or even number with a function. If a number is given as a parameter to that function, the function will return true if that number is Even and false if it is Odd. -------------------------------------------------------------------------------- /challanges1-to-72/problem22/problem.md: -------------------------------------------------------------------------------- 1 | একটা ফাংশন লিখবা যেটাকে তুমি কোন সংখ্যাকে ইনপুট হিসেবে দিলে সে সেই সংখ্যার square করে সেই square কে রিটার্ন করবে। 2 | 3 | অর্থাৎ তুমি ইনপুট হিসেবে 5 দিলে সেটাতে স্কয়ারে হিসেবে 25 আউটপুট হিসেবে পাবে। 4 | 5 | 6 | Write a function that if you give a number as input it will square that number and return that square. 7 | 8 | That is, if you give 5 as input, it will get 25 as output squared. -------------------------------------------------------------------------------- /challanges1-to-72/problem68/problme.md: -------------------------------------------------------------------------------- 1 | ## Problem 67: 2 | 3 | ### Create a function that takes a sorted array of numbers and a target value as input. The function should find two numbers in the array that add up to the target value. Return an array containing the indices of the two numbers. 4 | 5 | **Example `Input: ([1, 3, 6, 8, 11, 15], 9)` Example `Output: [1, 2] (numbers at indices 1 and 2: 3 + 6 = 9)`** 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /challanges1-to-72/problem25/problem25.js: -------------------------------------------------------------------------------- 1 | /* Write a function called make_avg() which will take an three integers and return the average of those values. 2 | */ 3 | 4 | 5 | function make_avg(num1, num2, num3){ 6 | var totalNumbers = num1 + num2 + num3 ; 7 | var avgNumber = totalNumbers / 3 ; 8 | return avgNumber; 9 | } 10 | 11 | var average = make_avg(60, 60, 59); 12 | console.log(parseFloat(average.toFixed(2))); -------------------------------------------------------------------------------- /challanges1-to-72/problem51/problem51.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | 4 | const student = { 5 | name: 'Fredie', 6 | age: 26, 7 | } 8 | 9 | 10 | Task: Console the value of 'age' 11 | 12 | problem provider : https://drive.google.com/file/d/1XcvIBe_rJlr6GY2rTnHlbIluTABXNhp7/view 13 | 14 | */ 15 | 16 | 17 | const student = { 18 | name: 'Fredie', 19 | age: 26, 20 | } 21 | 22 | const ageVaue = student.age; 23 | console.log(ageVaue); -------------------------------------------------------------------------------- /challanges1-to-72/problem18/problem.md: -------------------------------------------------------------------------------- 1 | তোমার যত বই আছে সেগুলার দাম নিয়ে একটা array লিখে ফেলো। যে বই গুলোর দাম ২০০ টাকার উপরে সেগুলাকে স্কিপ করবে। অর্থাৎ সেগুলাকে আউটপুট হিসেবে দেখাবে না। বাকিদের কে আউটপুট হিসেবে দেখাবে। দেখো করতে পারো কিনা। 2 | 3 | Write an array with the prices of all the books you have. The books whose price is above 200 rupees will be skipped. That is, they will not show as output. The rest will be displayed as output. See if you can. -------------------------------------------------------------------------------- /challanges1-to-72/problem37/problem.md: -------------------------------------------------------------------------------- 1 | Calculate the interest. Just how to calculate. Will do with that thought. Now there is no need to worry whether interest is good or bad. Just try to do it from the angle of how to write it in code if there is a formula. 2 | 3 | সুদের হিসাব করবে। জাস্ট হিসাব কেমনে করতে হয়। সেই চিন্তায় করবে। সুদ ভালো না খারাপ সেটা এখন চিন্তা করার দরকার নাই। জাস্ট একটা ফর্মুলা থাকলে সেটা কিভাবে কোড এ লিখতে হয় সেই এঙ্গেল থেকে করার চেষ্টা করো। -------------------------------------------------------------------------------- /challanges1-to-72/problem47/problem.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Practice Problem 47 4 | 5 | **Write an arrow function where it will do the following:** 6 | 1. It will take two array inputs 7 | 2. Combine the two arrays and assign them in a new array 8 | 3. Find the maximum number from the new array and return the 9 | result 10 | 11 | **Print the result.** 12 | 13 | 14 | problem getting source : https://drive.google.com/file/d/1Ut8t4Ed8V-U0Axtz4nbIXJhmxvMEMUe9/view -------------------------------------------------------------------------------- /challanges1-to-72/problem2/problem2.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var mathematicsResult = 75.25; 4 | var biologyResult = 65; 5 | var chemistryResult = 80; 6 | var physicsResult = 35.45; 7 | var banglaResult = 99.50; 8 | 9 | var totalMarks = mathematicsResult + biologyResult + chemistryResult + physicsResult + banglaResult; 10 | 11 | 12 | var averageMarks = totalMarks / 5 ; 13 | var averageMarksIn2Deci = averageMarks.toFixed(2); 14 | console.log(parseFloat(averageMarksIn2Deci)); 15 | 16 | -------------------------------------------------------------------------------- /challanges1-to-72/problem34/problem34.js: -------------------------------------------------------------------------------- 1 | /* You will be given Celsius as input to the function. 2 | You calculate the temperature and convert it to Fahrenheit and return the output */ 3 | 4 | function celsiusToFahren(celsius) { 5 | const inputCel = celsius; 6 | const fahrenheit = inputCel * 9 / 5 + 32; 7 | const massage = inputCel + "\xB0C Celsius equals to "+ fahrenheit + "\xB0F fahrenheit."; 8 | return massage; 9 | } 10 | 11 | console.log(celsiusToFahren(11)); -------------------------------------------------------------------------------- /challanges1-to-72/problme72/problme72.js: -------------------------------------------------------------------------------- 1 | /* 2 | Implement a JavaScript function to find the second smallest element in an array of numbers. The function should return the second smallest number. 3 | */ 4 | 5 | 6 | const findSecondSmallest = arr => { 7 | const sortedNum = arr.sort((a, b) => a - b); 8 | const secondSmallest = sortedNum[1]; 9 | return secondSmallest; 10 | } 11 | 12 | const result = findSecondSmallest([1, 3, 2, 5, 4]); 13 | console.log(result); -------------------------------------------------------------------------------- /challanges1-to-72/problem11/problem.md: -------------------------------------------------------------------------------- 1 | প্রাকটিস চ্যালেঞ্জ-১ 2 | 3 | প্রতিদিন তোমার কাজ কি? 4 | 5 | ১) রাত ৮ টা বাজে মডিউল আনলক করো 6 | 7 | ২) ফটাফট ভিডিও দেখে দেখে প্রাকটিস করো 8 | 9 | ৩) ভিডিও দেখতে দেখতে নোটস নাও 10 | 11 | ৪) মডিউল শেষ হলে পুরা মডিউল নিজে নিজে প্রাকটিস করো 12 | 13 | ৫) কোন কিছু বুঝতে না পারলে (চিন্তা করে দেখো এইখানে কিন্তু একটা শর্ত আছে ), সাপোর্ট সেশনে জয়েন করো 14 | 15 | এখন তোমার কাজ হচ্ছে একটা for লুপ 5 বার চালিয়ে উপরের জিনিসগুলা আউটপুট হিসেবে দেখানো। -------------------------------------------------------------------------------- /challanges1-to-72/problem24/problem24.js: -------------------------------------------------------------------------------- 1 | /* Write a function called foo() which prints "foo" 2 | and a function called bar() which prints "bar". 3 | Call function bar() in the foo() function after printing. 4 | What will be the output? Now call the foo() to see the output. */ 5 | 6 | 7 | 8 | 9 | function bar(){ 10 | 11 | return "bar"; 12 | }; 13 | 14 | function foo(){ 15 | 16 | console.log( "foo"); 17 | return bar(); 18 | }; 19 | 20 | console.log(foo()); 21 | 22 | -------------------------------------------------------------------------------- /challanges1-to-72/problem6/problem.md: -------------------------------------------------------------------------------- 1 | তাড়াহুড়া করে স্কুলের জন্য বের হচ্ছ কিন্তু রাস্তা পার হওয়ার সময় দেখলে, ট্রাফিক সিগন্যাল লাল রং। এই অবস্থায় যদি তুমি রাস্তা পার হওয়ার চেষ্টা কর, তাহলে ডেঞ্জার হতে পারে। যদি হলুদ রং হয় তাহলে তোমার থেমে যাওয়া উচিত। আর যদি ট্রাফিক সিগন্যাল গ্রিন হয় তাহলে তোমার রাস্তা পার হওয়া উচিত। তাই একটা কোড লিখে ফেলো। যেখানে আমরা signal নামে একটা ভেরিয়েবল থাকবে। সেটার মান green, yellow বা red হতে পারে। সেই অনুসারে ডিফারেন্ট ডিফারেন্ট কাজ হবে। তো, সেই কোড ফটাফট লিখে ফেলো। 2 | 3 | -------------------------------------------------------------------------------- /challanges1-to-72/problem16/problem16.js: -------------------------------------------------------------------------------- 1 | /* Create an array with the names of all the mobile phone models you have used so far. Then show the elements of that array as output one by one with a while loop */ 2 | 3 | 4 | var myPhones = ["Maximus", "Nokia-120", "Nokia-expres music", "Nokia-N70", "Symphany-w21", "Sumsung-Dose", "HUAWI-Y5II", "Samsung-j5", "Realme-C3"]; 5 | 6 | var i = 0; 7 | 8 | while( i < myPhones.length){ 9 | var phone = myPhones[i]; 10 | console.log(phone); 11 | i++; 12 | } -------------------------------------------------------------------------------- /challanges1-to-72/problem20/problem20.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* একটা ফাংশন লিখ যেটা যেকোন নামকে uppercase বা রেগুলার কেইস হিসেবে নিবে আর আউটপুট হিসেবে সেই নাম lowercase করে রিটার্ন করবে। 4 | 5 | Write a function that takes any name as uppercase or regular case and returns the name as lowercase as output. */ 6 | 7 | 8 | function makeLowercase(props){ 9 | 10 | const transferredCase = props.toLowerCase(); 11 | 12 | return transferredCase; 13 | } 14 | 15 | 16 | console.log(makeLowercase("SHOUrav")); -------------------------------------------------------------------------------- /challanges1-to-72/problem35/problem35.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* You will be given the function input as Fahrenheit. You calculate the temperature and convert it to Celsius and return the output */ 4 | 5 | 6 | function fahrenToCelsius(fahren) { 7 | const inputFahren = fahren; 8 | const celsius = (inputFahren -32) * 5 / 9 ; 9 | const massage = inputFahren + "\xB0F fahrenheit equals to "+ celsius.toFixed(2) + "\xB0C Celsius."; 10 | return massage; 11 | } 12 | 13 | console.log(fahrenToCelsius(11)); -------------------------------------------------------------------------------- /challanges1-to-72/problem28/problem.md: -------------------------------------------------------------------------------- 1 | You are in a hurry to go to your school on time. But when you are crossing the road, the traffic signal is red coloured. In this situation, if you try to cross the road, you may be in danger.If you notice a yellow coloured traffic signal, you should stop. If you notice a green coloured traffic signal, you should cross the road. So write a JS code, where there is a variable called signal. Its value can be green, yellow or red & we will get different activities as output depending on the variable. So, hurry up -------------------------------------------------------------------------------- /challanges1-to-72/problem26/problem26.js: -------------------------------------------------------------------------------- 1 | /* Write a function called make_avg() which will take an array of integers and the size of that array and return the average of those values. */ 2 | 3 | 4 | 5 | function make_avg(props1, props2){ 6 | var totalNumber = props1[0] + props1[1] + props1[2] + props1[3] + props1[4]; 7 | var avgNumber = totalNumber / props2; 8 | return avgNumber; 9 | }; 10 | 11 | 12 | var numbers = [10, 20, 30, 40, 50]; 13 | 14 | var numbers = make_avg(numbers, numbers.length); 15 | 16 | console.log(numbers); 17 | 18 | -------------------------------------------------------------------------------- /challanges1-to-72/problem18/problem18.js: -------------------------------------------------------------------------------- 1 | //Write an array with the prices of all the books you have. The books whose price is above 200 rupees will be skipped. That is, they will not show as output. The rest will be displayed as output. See if you can. 2 | 3 | 4 | var myBooksPrice = [90, 300, 85, 35, 125, 48, 98, 99, 20, 500, 820, 400]; 5 | 6 | for( var i = 0; i < myBooksPrice.length; i++){ 7 | 8 | var booksPrice = myBooksPrice[i]; 9 | 10 | if( booksPrice >= 100){ 11 | continue; 12 | } 13 | console.log(booksPrice); 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /challanges1-to-72/problem19/problem19.js: -------------------------------------------------------------------------------- 1 | 2 | //Task:Write a function that returns the multiplication table of 13 as output. 3 | 4 | //একটা ফাংশন লিখবা যেটা ১৩ এর নামতা (multiplication table) আউটপুট হিসেবে দেখাবে। 5 | 6 | 7 | function multiplicationTable(){ 8 | console.log("Multiplication Table Of 13"); 9 | console.log("**************************"); 10 | for(var i = 1; i <= 10; i++){ 11 | 12 | var baseNum = 13; 13 | console.log(baseNum, "*",i, "=", baseNum*i); 14 | }; 15 | 16 | }; 17 | 18 | multiplicationTable() 19 | 20 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Launch Program", 11 | "skipFiles": [ 12 | "/**" 13 | ], 14 | "program": "${file}" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /challanges1-to-72/problem22/problem22.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | একটা ফাংশন লিখবা যেটাকে তুমি কোন সংখ্যাকে ইনপুট হিসেবে দিলে সে সেই সংখ্যার square করে সেই square কে রিটার্ন করবে। 4 | 5 | অর্থাৎ তুমি ইনপুট হিসেবে 5 দিলে সেটাতে স্কয়ারে হিসেবে 25 আউটপুট হিসেবে পাবে। 6 | 7 | 8 | Write a function that if you give a number as input it will square that number and return that square. 9 | That is, if you give 5 as input, it will get 25 as output squared. 10 | 11 | */ 12 | 13 | 14 | function squareTheNum(num){ 15 | 16 | return num*num; 17 | } 18 | 19 | console.log(squareTheNum(5)); -------------------------------------------------------------------------------- /challanges1-to-72/problem40/problem.md: -------------------------------------------------------------------------------- 1 | ## Can you find out who will get the delicious cake? 2 | ### (Part II) 3 | This year, not only Jim & Dela but also Chinku are doing hard work to secure the first position. Can you find out who will get the delicious cake? 4 | 5 | **Input: The input line has three values, x (The marks Jim has got), y (The marks Dela has got) and z (The marks Chinku has got)** 6 | 7 | **Output: Print the name of the topper.** 8 | 9 | 1. Sample Input-1: 84 99 77 10 | - Sample Output-1: Dea 11 | 12 | 2. Sample Input-2: 69 97 99 13 | - Sample Output-2: Chinku -------------------------------------------------------------------------------- /challanges1-to-72/problem43/problem.md: -------------------------------------------------------------------------------- 1 | ## Who is the tallest? 2 | Tom and his friends are participating in the "Who is the tallest?" competition. As per the name, the person with the highest height will be the winner. Can you find who is the tallest among Tom and all of his friends? 3 | 4 | **Input: The input line can have multiple integer numbers, xi (The height of ith friend in cm).** 5 | 6 | **Output: Print the height of the tallest friend (cm).** 7 | 8 | 1. Sample Input-1: 157 134 188 9 | - Sample Output-1: 188 10 | 2. Sample Input-2: 167 100 120 165 137 11 | - Sample Output-2: 190 -------------------------------------------------------------------------------- /challanges1-to-72/problem8/problem.md: -------------------------------------------------------------------------------- 1 | You and your friends Tom, Jane, Peter and John got their final exam results. Your total 2 | score is 85, Tom’s total score is 66, Jane’s total score is 95, Peter’s total score is 56 3 | and John’s total score is 40. The grading chart is 4 | 80 or above A grade 5 | 60 or above B grade 6 | 50 or above C grade 7 | 40 or above D grade 8 | 39 or less => F grade 9 | 10 | Write a program to find your and your friends’ grades using if-else. 11 | 12 | 13 | 14 | [View problem source 📤](https://drive.google.com/file/d/1bfxye7A1p-BBJCQCXaiUetl_qyS2Vc1E/view) -------------------------------------------------------------------------------- /challanges1-to-72/problem4/problem.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Sarah’s mother is teaching her mathematics. She gave Sarah a number and asked her what the 5 | remainder would be if she divided the number by 5. Help Sarah write the program. 6 | Input: 7 | The first line of the input contains the number. 8 | Output: 9 | Print the remainder. 10 | 11 | Practice Problem 4 12 | 13 | Sample Input: 14 | 119 15 | 16 | Output: 17 | 4 18 | 19 | 20 | 21 | [Source: https://drive.google.com/drive/u/1/folders/1FbntkDTYNA33BuiqJ9TVF9-YWlqvhZch](https://drive.google.com/drive/u/1/folders/1FbntkDTYNA33BuiqJ9TVF9-YWlqvhZch) -------------------------------------------------------------------------------- /challanges1-to-72/problem2/problem.md: -------------------------------------------------------------------------------- 1 | Write a program to calculate the average marks of Mathematics, Biology, Chemistry, Physics, and 2 | Bangla of a student. 3 | Input: 4 | The first line of the input is the marks of the five subjects mentioned above, respectively. 5 | Output: 6 | Print the result in 2 decimal places. 7 | 8 | Practice Problem 2 9 | 10 | Sample Input: 11 | 75.25, 65, 80, 35.45, 99.50 12 | Output: 13 | 71.04 14 | 15 | [Source: https://drive.google.com/drive/u/1/folders/1FbntkDTYNA33BuiqJ9TVF9-YWlqvhZch](https://drive.google.com/drive/u/1/folders/1FbntkDTYNA33BuiqJ9TVF9-YWlqvhZch) 16 | -------------------------------------------------------------------------------- /challanges1-to-72/problem9/problem9.js: -------------------------------------------------------------------------------- 1 | 2 | /* You are given three numbers 13, 79, and 45. Write a program that will print the 3 | largest number using if-else. 4 | 5 | 6 | [View problem source 📤](https://drive.google.com/file/d/1bfxye7A1p-BBJCQCXaiUetl_qyS2Vc1E/view) */ 7 | 8 | 9 | var num1 = 13; 10 | var num2 = 79; 11 | var num3 = 45; 12 | 13 | if( num1 > num2 && num1 > num3){ 14 | console.log("The largest number is " + num1); 15 | } 16 | 17 | else if ( num2 > num3){ 18 | console.log("The largest number is " + num2); 19 | } 20 | 21 | else{ 22 | console.log("The largest number is " + num3); 23 | } -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/3.To_Be_or_Not_To_Be/To_Be_or_Not_To_Be.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {string} val 3 | * @return {Object} 4 | */ 5 | var expect = function (val) { 6 | return { 7 | toBe: function (val2) { 8 | if (typeof val2 === "number" && val === val2) return true; 9 | else throw new Error("Not Equal"); 10 | }, 11 | notToBe: function (val2) { 12 | if (typeof val2 !== "number" && val !== val2) return true; 13 | else throw new Error("Equal"); 14 | }, 15 | }; 16 | }; 17 | 18 | /** 19 | * expect(5).toBe(5); // true 20 | * expect(5).notToBe(5); // throws "Equal" 21 | */ 22 | -------------------------------------------------------------------------------- /challanges1-to-72/problem23/problem.md: -------------------------------------------------------------------------------- 1 | pizza নামের একটা object কে নিচের উদাহরণ মতো define করবা : 2 | 3 | 4 | 5 | const pizza = { 6 | 7 | toppings: ['cheese', 'sauce', 'pepperoni'], 8 | 9 | crust: 'deep dish', 10 | 11 | serves: 2 12 | 13 | } 14 | 15 | এবং pepperoni প্রিন্ট করবা। 16 | 17 | /////////////////////////////////////////////////////////////////// 18 | Define an object named pizza as in the following example: 19 | 20 | 21 | 22 | const pizza = { 23 | 24 | toppings: ['cheese', 'sauce', 'pepperoni'], 25 | 26 | crust: 'deep dish', 27 | 28 | Serves: 2 29 | 30 | } 31 | 32 | and print pepperoni. -------------------------------------------------------------------------------- /challanges1-to-72/problem31/problem31.js: -------------------------------------------------------------------------------- 1 | /* এমন একটা ফ্যাংশনা লিখো যেটাকে তুমি ঘন্টাকে ইনপুট প্যারামিটার হিসেবে দিবে। 2 | আর সে সেই ঘন্টাকে মিনিটে কনভার্ট করে মিনিট রিটার্ন করবে। 3 | 4 | Write a function that takes the hour as an input parameter. 5 | And it will convert those hours to minutes and return minutes. */ 6 | 7 | 8 | function hoursToMinutes(hours){ 9 | 10 | const minutes = hours * 60; 11 | return minutes; 12 | }; 13 | 14 | 15 | const hoursHaveToConvert = 24; 16 | const convertingMinutes = hoursToMinutes(hoursHaveToConvert); 17 | 18 | console.log(hoursHaveToConvert,"hours equals to",convertingMinutes,"minutes."); -------------------------------------------------------------------------------- /challanges1-to-72/problem1/problem.md: -------------------------------------------------------------------------------- 1 | Harry’s mom gave him money and asked him to buy some oranges and apples. Write a program to 2 | help Harry calculate how much money the shopkeeper will return. 3 | Input: 4 | The first line of the input is the taka Harry’s mom gave him. 5 | The second line is the cost of 1 kg of oranges and 1 kg of apples. 6 | Output: 7 | Print the result. 8 | 9 | Practice Problem 1 10 | 11 | Sample Input: 12 | 1000 13 | 700 14 | Output: 15 | 300 16 | 17 | 18 | [Source: https://drive.google.com/drive/u/1/folders/1FbntkDTYNA33BuiqJ9TVF9-YWlqvhZch](https://drive.google.com/drive/u/1/folders/1FbntkDTYNA33BuiqJ9TVF9-YWlqvhZch) -------------------------------------------------------------------------------- /challanges1-to-72/problem29/problem29.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* Write a function called leapYear() and check whether the next year i.e. 2023 is a leap year or not. 4 | The function will return true if it is a leap year and false if it is not a leap year. */ 5 | 6 | 7 | function leapYear(year){ 8 | 9 | if((year % 4 === 0) && (year % 100 !== 0) || ( year % 400 === 0)){ 10 | return true; 11 | } 12 | 13 | else{ 14 | return false; 15 | } 16 | }; 17 | 18 | 19 | 20 | const checkTheYear = 2023; 21 | const isLeapYear = leapYear(checkTheYear); 22 | console.log("Is",checkTheYear,"leap year?", " Answer:",isLeapYear,"." ); -------------------------------------------------------------------------------- /challanges1-to-72/problem21/problem.md: -------------------------------------------------------------------------------- 1 | fullName নামে একটা ফাংশন তৈরী কর যেটা তোমার নামের প্রথম অংশ এবং তোমার নামের শেষের অংশ প্যারামিটার হিসেবে নিবে। 2 | আর তোমার নামের দুই অংশ জোড়া দিয়ে আউটপুট হিসেবে তোমার পূর্ন নাম রিটার্ন করে দিবে। 3 | যেমন ধরো, hablu এবং kanto ইনপুট প্যারামিটার হিসেবে দিলে আউটপুট হিসেবে hablu kanto রিটার্ন করবে। 4 | 5 | 6 | Create a function called 'fullName' that takes the first part of your name and the last part of your name as parameters. 7 | And it will return your full name as the output by concatenating the two parts of your name. 8 | For example, given hablu and kanto as input parameters, hablu will return kanto as output. -------------------------------------------------------------------------------- /challanges1-to-72/problem58/problem.md: -------------------------------------------------------------------------------- 1 | ## Problem 58: 2 | 3 | ``` 4 | let students = { 5 | 2222: { 6 | name: "Jack", 7 | section: "C", 8 | class: "IX", 9 | address: { 10 | "building no": 12, 11 | street: "St. Jonson", 12 | city: "Petersburg", 13 | country: "UK", 14 | }, 15 | }, 16 | 3333: { 17 | name: "Herry", 18 | section: "D", 19 | class: "X", 20 | address: { 21 | "building no": 85, 22 | street: "DC road", 23 | city: "Kachukhet", 24 | country: "Bangladesh", 25 | }, 26 | }, 27 | }; 28 | 29 | ``` 30 | 31 | ### display `Petersburg` ` Herry` 32 | 33 | 34 | -------------------------------------------------------------------------------- /challanges1-to-72/problem61/problem.md: -------------------------------------------------------------------------------- 1 | ## Problem 61: 2 | 3 | ``` 4 | let data = { 5 | data: [ 6 | { 7 | bookId: 1, 8 | bookDetails: { name: "habluder adda", category: "XYZ", price: "20$" }, 9 | bookCategory: "Basic", 10 | }, 11 | { 12 | bookId: 2, 13 | bookDetails: { 14 | name: "gobluder adda", 15 | category: "ABC", 16 | price: "40$", 17 | }, 18 | bookCategory: "Beginner", 19 | }, 20 | ], 21 | }; 22 | 23 | ``` 24 | 25 | ### Display `habluder adda` and `Beginner` 26 | 27 | 28 | 29 | 30 | problem getting source : https://drive.google.com/file/d/1oRju8zbVD3O3oyntU0gPfW9-bp8R11lk/view -------------------------------------------------------------------------------- /challanges1-to-72/problem52/problem52.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | let data = { 4 | location:[ 5 | { 6 | latitude: '34.5, 37.8', 7 | longitude:'98.77, 58.7', 8 | city: 'Hyderabad', 9 | country: 'India', 10 | } 11 | ] 12 | }; 13 | 14 | 15 | Console the value of city 16 | 17 | */ 18 | 19 | 20 | 21 | let data = { 22 | location:[ 23 | { 24 | latitude: '34.5, 37.8', 25 | longitude:'98.77, 58.7', 26 | city: 'Hyderabad', 27 | country: 'India', 28 | } 29 | ] 30 | }; 31 | 32 | const cityOfData = data.location[0].city; 33 | console.log(cityOfData); 34 | -------------------------------------------------------------------------------- /challanges1-to-72/problem57/problem.md: -------------------------------------------------------------------------------- 1 | 2 | ## Problem 57: 3 | 4 | ``` 5 | let activities = { 6 | activity1: [ 7 | { 8 | name: "listen on spotify", 9 | song_list: { 10 | song_1: "abc", 11 | song_2: "bcd", 12 | }, 13 | id: 1, 14 | }, 15 | { 16 | name: "listen music through bot", 17 | 18 | song_list: { 19 | song_1: "wxy", 20 | song_2: "xyz", 21 | }, 22 | id: 2, 23 | }, 24 | ], 25 | }; 26 | ``` 27 | 28 | ### How will you get the output 29 | 30 | 1. `abc` 31 | 2. `xyz` 32 | 33 | 34 | 35 | problem provider : https://drive.google.com/file/d/1oRju8zbVD3O3oyntU0gPfW9-bp8R11lk/view -------------------------------------------------------------------------------- /challanges1-to-72/problem44/problem.md: -------------------------------------------------------------------------------- 1 | 2 | ## Practice Problem 44 3 | 4 | 1. Write an arrow function that will take **3** parameters, will multiply 5 | the parameters and will return the result. 6 | 7 | 2. Write the following sentence in **three lines** and print the result: 8 | **I am a web developer. I love to code. I love to eat biryani.** 9 | 10 | 3. Write an arrow function that will take **2** parameters: One parameter 11 | will come from you and the other parameter will be a default 12 | parameter. Add these two parameters and return the result. 13 | 14 | 15 | 16 | 17 | 18 | problem source: https://drive.google.com/file/d/1Ut8t4Ed8V-U0Axtz4nbIXJhmxvMEMUe9/view?usp=sharing -------------------------------------------------------------------------------- /challanges1-to-72/problem50/problem.md: -------------------------------------------------------------------------------- 1 | ## Practice Problem 50 2 | 3 | ``` 4 | const people = [ 5 | {name: 'Meena', age: 20}, 6 | {name: 'Rina', age: 15}, 7 | {name: 'Suchorita', age: 22} 8 | ]; 9 | 10 | ``` 11 | 12 | 1. `Challenging:` Follow above array of objects. So, you have 3 objects as 13 | array element. Can you find out the total sum from here? 14 | 15 | **20 + 15 + 22 = 57 . The output will be 57** 16 | 17 | What are you thinking? Yeah! Do it with `for loop.` I know you can do it. 18 | But! Wait !! Wait !!! Do the same task using `array.reduce()` method. 19 | 20 | 21 | problem provider : https://drive.google.com/file/d/1XcvIBe_rJlr6GY2rTnHlbIluTABXNhp7/view -------------------------------------------------------------------------------- /challanges1-to-72/problem3/problme.md: -------------------------------------------------------------------------------- 1 | John’s teacher gave him two variables. Each variable contains a string. John’s teacher asked him to 2 | combine these two strings and print them in one line. Help John write the program. 3 | Input: 4 | The first and the second lines of the input contain the strings. 5 | Output: 6 | Print the result in one line. 7 | 8 | Practice Problem 3 9 | 10 | Sample Input: 11 | I am going to be 12 | an awesome web developer 13 | Output: 14 | I am going to be an awesome web developer 15 | 16 | 17 | [Source: https://drive.google.com/drive/u/1/folders/1FbntkDTYNA33BuiqJ9TVF9-YWlqvhZch](https://drive.google.com/drive/u/1/folders/1FbntkDTYNA33BuiqJ9TVF9-YWlqvhZch) -------------------------------------------------------------------------------- /challanges1-to-72/problem10/problem10.js: -------------------------------------------------------------------------------- 1 | /* You are given a triangle with the sides 9, 8, 9. Write a program to check whether a 2 | triangle is Isosceles or not using if-else. 3 | 4 | Isosceles => two sides are equal 5 | 6 | 7 | [View problem source 📤](https://drive.google.com/file/d/1bfxye7A1p-BBJCQCXaiUetl_qyS2Vc1E/view) */ 8 | 9 | 10 | var sideOfTriangle1 = 9; 11 | var sideOfTriangle2 = 8; 12 | var sideOfTriangle3 = 9; 13 | 14 | 15 | if( sideOfTriangle1 == sideOfTriangle2 || sideOfTriangle1 == sideOfTriangle3 || sideOfTriangle2 == sideOfTriangle3){ 16 | console.log("The triangle is Isosceles"); 17 | } 18 | 19 | else{ 20 | console.log("The triangle is not Isosceles"); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /challanges1-to-72/problem33/problem33.js: -------------------------------------------------------------------------------- 1 | /* Write a function findOddSum() that will take the array [5, 7, 8, 10, 45, 30] 2 | as the input parameter and will return the sum of the odd numbers. */ 3 | 4 | 5 | 6 | function findOddSum(numbers){ 7 | 8 | let sum = 0; 9 | for(let i = 0; i < numbers.length; i++){ 10 | 11 | const index = i; 12 | const number = numbers[i]; 13 | 14 | if(number % 2 === 1){ 15 | sum = sum + number; 16 | } 17 | 18 | } 19 | return sum; 20 | } 21 | 22 | 23 | const givenNumbers = [5, 7, 8, 10, 45, 30] ; 24 | 25 | const sumOfAllOdds = findOddSum(givenNumbers); 26 | console.log("Total of all Odd number is",sumOfAllOdds); -------------------------------------------------------------------------------- /challanges1-to-72/problem30/problem30.js: -------------------------------------------------------------------------------- 1 | /* তোমার বয়স কি odd নাকি even সংখ্যা সেটা চেক কর একটা ফাংশন দিয়ে। 2 | সেই ফাংশনকে কোন সংখ্যা প্যারামিটার হিসেবে দিলে, সেই সংখ্যা Even হলে ফাংশন true রিটার্ন করবে আর Odd হলে false রিটার্ন করবে। 3 | 4 | Check whether your age is odd or even number with a function. 5 | If a number is given as a parameter to that function, the function will return true if that number is Even and false if it is Odd. */ 6 | 7 | 8 | function oddOrEven(age){ 9 | 10 | if( age % 2 === 0){ 11 | return true; 12 | } 13 | else{ 14 | return false; 15 | } 16 | }; 17 | 18 | 19 | const myAge =21; 20 | const checkMyAge = oddOrEven(myAge); 21 | console.log(checkMyAge); -------------------------------------------------------------------------------- /challanges1-to-72/problem61/problem61.js: -------------------------------------------------------------------------------- 1 | let data = { 2 | data: [ 3 | { 4 | bookId: 1, 5 | bookDetails: { name: "habluder adda", category: "XYZ", price: "20$" }, 6 | bookCategory: "Basic", 7 | }, 8 | { 9 | bookId: 2, 10 | bookDetails: { 11 | name: "gobluder adda", 12 | category: "ABC", 13 | price: "40$", 14 | }, 15 | bookCategory: "Beginner", 16 | }, 17 | ], 18 | }; 19 | 20 | 21 | /* ======== Display `habluder adda` and `Beginner` ============ */ 22 | 23 | const firstDisplay = data.data[0].bookDetails.name; 24 | console.log(firstDisplay); 25 | 26 | const secondDisplay = data.data[1].bookCategory; 27 | console.log(secondDisplay); 28 | -------------------------------------------------------------------------------- /challanges1-to-72/problem41/problem41.js: -------------------------------------------------------------------------------- 1 | /* ## Find the expensive product */ 2 | 3 | function findTheExpesive(product1, product2, product3){ 4 | const mostExpensive = Math.max(product1, product2, product3); 5 | if( mostExpensive === product1 ){ 6 | return "Most expensive is 'Shirt' "; 7 | } 8 | 9 | else if( mostExpensive === product2 ){ 10 | return "Most expensive is 'Pants' "; 11 | } 12 | 13 | else{ 14 | return "Most expensive is 'Watch' "; 15 | } 16 | }; 17 | 18 | 19 | 20 | 21 | const shirtsPrice = 1500; 22 | const pantsPrice = 5000; 23 | const watchPrice = 3500; 24 | 25 | const mostExpensive = findTheExpesive(shirtsPrice, pantsPrice, watchPrice); 26 | console.log(mostExpensive); -------------------------------------------------------------------------------- /challanges1-to-72/problem37/problem37.js: -------------------------------------------------------------------------------- 1 | /* Calculate the interest. Just how to calculate. 2 | Will do with that thought. Now there is no need to worry whether interest is good or bad. 3 | Just try to do it from the angle of how to write it in code if there is a formula. */ 4 | 5 | 6 | 7 | function calculateInterest(capital, rate){ 8 | const interest = capital / 100 * rate ; 9 | const massage = "Your Capital is " + capital + " . And rate of Interest is "+ rate + ". So your total yearly profit / Interest is " + interest.toFixed(2) ; 10 | return massage; 11 | }; 12 | 13 | 14 | 15 | 16 | const clintsCapital = 7410; 17 | const rateOfInterest = 3; 18 | 19 | const profit = calculateInterest(clintsCapital, rateOfInterest); 20 | console.log(profit); -------------------------------------------------------------------------------- /challanges1-to-72/problem57/problem57.js: -------------------------------------------------------------------------------- 1 | let activities = { 2 | activity1: [ 3 | { 4 | name: "listen on spotify", 5 | song_list: { 6 | song_1: "abc", 7 | song_2: "bcd", 8 | }, 9 | id: 1, 10 | }, 11 | { 12 | name: "listen music through bot", 13 | 14 | song_list: { 15 | song_1: "wxy", 16 | song_2: "xyz", 17 | }, 18 | id: 2, 19 | }, 20 | ], 21 | }; 22 | 23 | 24 | /* 25 | How will you get the output 26 | abc 27 | xyz 28 | */ 29 | 30 | 31 | const firstOutput = activities['activity1'][0]['song_list']['song_1']; 32 | console.log(firstOutput); 33 | 34 | const secondOutput = activities['activity1'][1]['song_list']['song_2']; 35 | console.log(secondOutput); 36 | 37 | -------------------------------------------------------------------------------- /challanges1-to-72/problem39/problem.md: -------------------------------------------------------------------------------- 1 | ## Can you find out who will get the delicious cake? 2 | ### (Part 1) 3 | Jim is a meritorious student. He secures first place in his class all the time. 4 | This year, Dela has joined his class. She was also a topper at her previous school. 5 | On the day of result publication, the teacher comes into the class with a delicious cake and says that "Jim & Dela, whoever is the topper, 6 | will get this tasty cake." Can you find out who will get this cake? 7 | 8 | **Input: The input line has two values, m (The marks Jim has got) and n (The marks Dela has got).** 9 | **Output: Print the name of the topper.** 10 | 11 | 1. Sample Input-1: 84 75 12 | - Sample Output-1: Jim 13 | 14 | 15 | 2. Sample Input-2: 69 97 16 | - Sample Output-2: Dela -------------------------------------------------------------------------------- /challanges1-to-72/problem60/problem.md: -------------------------------------------------------------------------------- 1 | 2 | ## Problme 60: 3 | 4 | ``` 5 | const studentData = [ 6 | { 7 | class: 10, 8 | details: [ 9 | { 10 | studentId: "1", 11 | gradingDetails: [{ grade: "A" }], 12 | }, 13 | { 14 | studentId: "2", 15 | gradingDetails: [{ grade: "B" }], 16 | }, 17 | ], 18 | }, 19 | { 20 | class: 11, 21 | details: [ 22 | { 23 | studentId: 3, 24 | gradingDetails: [{ grade: "B" }], 25 | }, 26 | { 27 | studentId: 4, 28 | gradingDetails: [{ grade: "D" }], 29 | }, 30 | ], 31 | }, 32 | ]; 33 | 34 | ``` 35 | 36 | ## Display `B` `D` 37 | 38 | problem getting source: https://drive.google.com/file/d/1oRju8zbVD3O3oyntU0gPfW9-bp8R11lk/view -------------------------------------------------------------------------------- /challanges1-to-72/problem64/problem64.js: -------------------------------------------------------------------------------- 1 | 2 | /* ===================================================== 3 | ------ An Ideal Example of Callback Function -------- 4 | ===================================================== */ 5 | 6 | const totalMoney = (depositOne, depositTwo, interest) => { 7 | 8 | const totalDepositAmount = depositOne + depositTwo ; 9 | const profit = interest(totalDepositAmount); 10 | return totalDepositAmount + parseFloat(profit) ; 11 | } 12 | 13 | 14 | const totalInterest = totalDeposit => { 15 | const interestRate = 7 / 100 ; // Suppose Interest Rate is 7 % 16 | return (totalDeposit*interestRate).toFixed(2); 17 | }; 18 | 19 | 20 | const grandTotal = totalMoney(900, 1100, totalInterest); 21 | 22 | console.log(grandTotal); 23 | 24 | -------------------------------------------------------------------------------- /challanges1-to-72/problem5/problem.md: -------------------------------------------------------------------------------- 1 | প্রাকটিস চ্যালেঞ্জ -১: 2 | 3 | ক্লাস সেভের এর ফাইনাল এক্সাম এ তুমি ফার্স্ট হয়েছ। তোমার বন্ধু আলিয়া, ডালিয়া, সালিয়া, মালিয়া, লিলিয়া আর জ্বালাইয়া - তাদের grade তুমি জানো না। তবে তাদের নম্বর জানো. আলিয়া 95 পেয়েছে, ডালিয়া 66 পেয়েছে, সালিয়া 80 পেয়েছে, মালিয়া পেয়েছে 59, লিলিয়া পেয়েছে 47, জ্বালাইয়া পেয়েছে 77। তুমি JS code দিয়ে তাদের grade বের করে দিতে পারবে? 4 | 5 | ১) যারা ৫০ এর নিচে পেয়েছে, তাদের grade F. 6 | 7 | ২) যারা ৫০ বা তার উপরে পেয়েছে, অথবা ৬০ এর নিচে পেয়েছে, তাদের grade D. 8 | 9 | ৩) যারা ৬০ বা তার উপরে পেয়েছে, অথবা ৭০ এর নিচে পেয়েছে, তাদের grade C. 10 | 11 | ৪) যারা ৭০ বা তার উপরে পেয়েছে, অথবা ৮০ এর নিচে পেয়েছে, তাদের grade B. 12 | 13 | ৫) যারা ৮০ বা তার উপরে পেয়েছে, অথবা ৯০ এর নিচে পেয়েছে, তাদের grade A. 14 | 15 | ৬) যারা ৯০ বা তার উপরে পেয়েছে, তাদের grade A+. -------------------------------------------------------------------------------- /challanges1-to-72/problem59/problem.md: -------------------------------------------------------------------------------- 1 | 2 | ## Problem 59: 3 | 4 | ``` 5 | let instructor = { 6 | name: "Jhankar Mahbub", 7 | entrepreneur: true, 8 | additionalData: { 9 | writer: true, 10 | favoriteHobbies: ["travelling", "Coding"], 11 | books: ["programming er bolod to bos", "programming er coddogosti"], 12 | moreDetails: { 13 | favoriteBasketballTeam: "XYZ", 14 | isYoungest: true, 15 | hometown: { 16 | city: "ABC", 17 | state: "VW", 18 | }, 19 | countriesLivedIn: ["Bangladesh", "New York"], 20 | }, 21 | }, 22 | }; 23 | 24 | ``` 25 | 26 | ### How will you display 27 | - programming er coddogosti 28 | - VW 29 | - Bangladesh 30 | 31 | problem getting source : https://drive.google.com/file/d/1oRju8zbVD3O3oyntU0gPfW9-bp8R11lk/view 32 | 33 | 34 | -------------------------------------------------------------------------------- /challanges1-to-72/problem63/problem63.js: -------------------------------------------------------------------------------- 1 | /* ================================================= 2 | ------ Programme for Finding Palindrome -------- 3 | ================================================= */ 4 | 5 | 6 | const findPalindrome = value => { 7 | const valueIntoStr = value.toString(); 8 | const valueIntoReverseStr = valueIntoStr.split("").reverse().join(""); 9 | 10 | if(valueIntoStr === valueIntoReverseStr){ 11 | const message = `Your input text is "${value}" which is a "Palindrome".`; 12 | console.log(message); 13 | } 14 | else{ 15 | const message = `Your input text is "${value}" which is "Not A Palindrome".`; 16 | console.log(message); 17 | } 18 | } 19 | 20 | findPalindrome("eye"); 21 | findPalindrome("madam"); 22 | findPalindrome("Shourav"); -------------------------------------------------------------------------------- /challanges1-to-72/problem46/problem46.js: -------------------------------------------------------------------------------- 1 | /* Write an arrow function where it will do the following:** 2 | 3 | 1. Square each array element 4 | 2. Calculate the sum of the squared elements 5 | 3. Return the average of the sum of the squared elements 6 | 7 | **Print the result. */ 8 | 9 | 10 | 11 | const complexMathOperation = nums => { 12 | 13 | let sumOfAllNumsSqure = 0; 14 | 15 | for(const num of nums){ 16 | 17 | const squareOfNum = num * num; 18 | sumOfAllNumsSqure = sumOfAllNumsSqure + squareOfNum ; 19 | } 20 | 21 | const averageOfAllNumsTotal = sumOfAllNumsSqure / nums.length; 22 | return averageOfAllNumsTotal; 23 | } 24 | 25 | 26 | const numbers = [10, 13, 45, 46]; 27 | /* const numbers = [2, 3, 4]; */ 28 | const result = complexMathOperation(numbers); 29 | console.log(result.toFixed(2)); -------------------------------------------------------------------------------- /challanges1-to-72/problem71/problem71.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Implement a function that converts a Roman numeral to an integer. The function should take a Roman numeral string (e.g., "IX" or "XXI") as input and return the corresponding integer value. 4 | 5 | */ 6 | 7 | function romanToIntNum(romanNum) { 8 | let numInt = 0; 9 | const romValues = {M:1000, D:500, C:100, L:50, X:10, V:5, I:1}; 10 | 11 | for(let i = 0; i < romanNum.length; i++){ 12 | 13 | if(romValues[romanNum[i]] < romValues[romanNum[i+1]]){ 14 | numInt -= romValues[romanNum[i]]; 15 | } 16 | else{ 17 | numInt += romValues[romanNum[i]] 18 | } 19 | } 20 | return numInt; 21 | } 22 | 23 | console.log(romanToIntNum("CXM")); 24 | console.log(romanToIntNum("XX")); 25 | console.log(romanToIntNum("VI")); -------------------------------------------------------------------------------- /challanges1-to-72/problem55/problem.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Problem 55: 4 | 5 | ``` 6 | let data = { 7 | Sophia: { 8 | id: 33, 9 | study: [ 10 | { 11 | primary: [ 12 | { school_name: "ABC primary school" }, 13 | { location: "Peters burg" }, 14 | ], 15 | }, 16 | { 17 | secondary: [ 18 | { school_name: "ABC secondary school" }, 19 | 20 | { location: "St Lorence" }, 21 | ], 22 | }, 23 | ], 24 | }, 25 | }; 26 | 27 | ``` 28 | 29 | ### How will you access Sophia’s secondary school location? 30 | 31 | problem provider's source : https://drive.google.com/file/d/1oRju8zbVD3O3oyntU0gPfW9-bp8R11lk/view -------------------------------------------------------------------------------- /challanges1-to-72/problem67/problem67.js: -------------------------------------------------------------------------------- 1 | /* Write a JavaScript program to find the most frequent element in an array and return it. 2 | 3 | Example Input: [3, 5, 2, 5, 3, 3, 1, 4, 5] Example Output: 3 */ 4 | 5 | const findMostFrequent = arrayOfNums => { 6 | const frequency = {}; 7 | arrayOfNums.map(element => frequency[element] = frequency[element] + 1 || 1); 8 | 9 | const allNumbers = Object.keys(frequency); 10 | const NumbersRepetition = Object.values(frequency); 11 | const maxFrequentValue = Math.max(...NumbersRepetition); 12 | const maxFrequentsIndex = NumbersRepetition.findIndex ( x => x === maxFrequentValue); 13 | 14 | const mostFrequentElement = allNumbers[maxFrequentsIndex]; 15 | return mostFrequentElement; 16 | } 17 | 18 | 19 | console.log(findMostFrequent([3, 5, 2, 5, 3, 3, 1, 4, 5])); -------------------------------------------------------------------------------- /challanges1-to-72/problem7/proble7.js: -------------------------------------------------------------------------------- 1 | /* You are given an array: 2 | 3 | var fruits = ['Apple', 'Banana', 'Orange']; 4 | 5 | a) Find the index of ‘Banana’ and replace ‘Banana’ with ‘Mango’. 6 | b) Remove ‘Orange’ and add ‘Watermelon’. 7 | 8 | 9 | 10 | [View problem source 📤](https://drive.google.com/file/d/1bfxye7A1p-BBJCQCXaiUetl_qyS2Vc1E/view) */ 11 | 12 | var fruits = ['Apple', 'Banana', 'Orange']; 13 | 14 | 15 | // Part (a) 1.index of ‘Banana’ 16 | var bananaIndex = fruits.indexOf("Banana"); 17 | console.log(bananaIndex); 18 | 19 | // Part (a) 2. replace ‘Banana’ with ‘Mango’. 20 | 21 | fruits[1]='Mango'; 22 | console.log(fruits); 23 | 24 | // Part (b) 1. Removing ‘Orange’ 25 | 26 | fruits.pop() 27 | console.log( fruits); 28 | 29 | // Part (b) 2. Adding ‘Watermelon’ 30 | 31 | fruits.push("Watermelon"); 32 | console.log(fruits); -------------------------------------------------------------------------------- /challanges1-to-72/problem56/problem.md: -------------------------------------------------------------------------------- 1 | ## Problem 56: 2 | 3 | ``` 4 | let data = [ 5 | { 6 | pHeroCourses: { 7 | "course-x": "web development", 8 | }, 9 | }, 10 | 11 | { 12 | pHeroCourses: { 13 | "course-y": "phitron", 14 | }, 15 | }, 16 | 17 | { 18 | pHeroCourses: { 19 | "course-z": "acc", 20 | }, 21 | }, 22 | 23 | { 24 | pHeroCourses: { 25 | "course-xyz": "level-2", 26 | }, 27 | 28 | locationField: { 29 | "en-US": { 30 | lat: 19.28563, 31 | lon: 72.8691, 32 | }, 33 | }, 34 | }, 35 | ]; 36 | ``` 37 | 38 | ### How will you get the output `[uses 2D matrix concept]` 39 | 1. level-2 40 | 2. 72.8621 41 | 42 | 43 | 44 | 45 | 46 | problem getting source: https://drive.google.com/file/d/1oRju8zbVD3O3oyntU0gPfW9-bp8R11lk/view -------------------------------------------------------------------------------- /challanges1-to-72/problem12/problem12.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /* If you have more than 80000 Taka you will buy a macbook, 5 | if the ammount is more than 60000 you will buy a gamming laptop, if the amount is more than 40000 you will buy a lenovo yoga. If the amount is 20000 taka then you buy a secondhand laptop. Otherwise you will use a smart phone. Now solve the problem. */ 6 | 7 | 8 | var myBudget = 50000; 9 | 10 | if( myBudget > 80000){ 11 | console.log("I will buy a mac book"); 12 | } 13 | 14 | else if( myBudget > 60000){ 15 | console.log("I will buy a gaming laptop. "); 16 | } 17 | 18 | else if (myBudget > 40000){ 19 | console.log("I will buy a lenovo youg"); 20 | } 21 | 22 | else if ( myBudget > 20000){ 23 | console.log("I will buy a second hand laptop"); 24 | } 25 | 26 | else{ 27 | console.log("I will work with my smartphone"); 28 | } -------------------------------------------------------------------------------- /challanges1-to-72/problem23/problem23.js: -------------------------------------------------------------------------------- 1 | /* pizza নামের একটা object কে নিচের উদাহরণ মতো define করবা : 2 | 3 | 4 | 5 | const pizza = { 6 | 7 | toppings: ['cheese', 'sauce', 'pepperoni'], 8 | 9 | crust: 'deep dish', 10 | 11 | serves: 2 12 | 13 | } 14 | 15 | এবং pepperoni প্রিন্ট করবা। 16 | 17 | /////////////////////////////////////////////////////////////////// 18 | Define an object named pizza as in the following example: 19 | 20 | 21 | 22 | const pizza = { 23 | 24 | toppings: ['cheese', 'sauce', 'pepperoni'], 25 | 26 | crust: 'deep dish', 27 | 28 | Serves: 2 29 | 30 | } 31 | 32 | and print pepperoni. */ 33 | 34 | 35 | 36 | 37 | const pizza = { 38 | 39 | toppings: ['cheese', 'sauce', 'pepperoni'], 40 | 41 | crust: 'deep dish', 42 | 43 | Serves: 2 44 | 45 | }; 46 | 47 | console.log(pizza.toppings[2]); 48 | -------------------------------------------------------------------------------- /challanges1-to-72/problem48/problem.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Practice Problem 47 ( map(), filter(), find() ) 4 | 5 | 1. You have **an odd array (array with odd numbers). [ 1, 3, 5, 7, 9 ].** 6 | Now convert this array **into an even array (array with even numbers). [ 2, 4, 6, 8, 10 ].** 7 | Do this using `for loop` & `array.map()` 8 | method. Hints: add one to any odd number and it will become an even 9 | number. 10 | 11 | 2. You are given **an array say: [33, 50, 79, 78, 90, 101, 30 ]**. Now 12 | return/get all the elements which are divisible by 10 using 13 | `array.filter()` method. 14 | 15 | 3. Now do the **same task of question 2.** But do this using `array.find()` 16 | method. Then **compare the output** of question 2 & question 3. 17 | 18 | 19 | 20 | prblem provider source : https://drive.google.com/file/d/1XcvIBe_rJlr6GY2rTnHlbIluTABXNhp7/view 21 | 22 | -------------------------------------------------------------------------------- /challanges1-to-72/problem21/problem21.js: -------------------------------------------------------------------------------- 1 | /* fullName নামে একটা ফাংশন তৈরী কর যেটা তোমার নামের প্রথম অংশ এবং তোমার নামের শেষের অংশ প্যারামিটার হিসেবে নিবে। 2 | আর তোমার নামের দুই অংশ জোড়া দিয়ে আউটপুট হিসেবে তোমার পূর্ন নাম রিটার্ন করে দিবে। 3 | যেমন ধরো, hablu এবং kanto ইনপুট প্যারামিটার হিসেবে দিলে আউটপুট হিসেবে hablu kanto রিটার্ন করবে। 4 | 5 | 6 | Create a function called 'fullName' that takes the first part of your name and the last part of your name as parameters. 7 | And it will return your full name as the output by concatenating the two parts of your name. 8 | For example, given hablu and kanto as input parameters, hablu will return kanto as output. */ 9 | 10 | 11 | function fullName(firstName, lastName){ 12 | var myName = firstName + " " + lastName; 13 | 14 | return myName; 15 | }; 16 | 17 | 18 | console.log(fullName("Shourav","Raj")); -------------------------------------------------------------------------------- /challanges1-to-72/problem15/problem15.js: -------------------------------------------------------------------------------- 1 | /* Create an array with the names of all the things you have learned in this lesson. Then use a for loop to output all elements of that array. */ 2 | 3 | 4 | var itemsLearnt = ["Variable declaration", "Data types","String concatenation", "ParseInt()", "ParseFloat()", "toFixed()", "Math operations","Conditions", "Multiple conditions", "Multi stage conditions", "Array","Find array elements by index", "Find index by array element", "Array length", "Update array element", "Add element at the last of an array", "Add element at first of an array", "Remove the last element of an array", "Remove first element of an array", "While loop", "For loop", "Loop break", "Loop continue", "Loop reverse" ]; 5 | 6 | for( var i = 0; i < itemsLearnt.length; i++){ 7 | 8 | var item = itemsLearnt[i]; 9 | console.log(i + ". " + item); 10 | } -------------------------------------------------------------------------------- /challanges1-to-72/problem32/problem32.js: -------------------------------------------------------------------------------- 1 | /* Write a function findLeapYear() that will take the array 2 | [2023,2024,2025,2028,2030] as the input parameter and will check if 3 | each year is a leap year. If a year is a leap year insert that year in a 4 | new array, return the new array and print the result. */ 5 | 6 | 7 | 8 | function findLeapYear(years){ 9 | const leapYear = []; 10 | for( let i = 0; i < years.length; i++){ 11 | const index = i; 12 | const year = years[index]; 13 | if(( year % 4 === 0) && (year % 100 !== 0) || (year % 400 === 0) ){ 14 | leapYear.push(year); 15 | } 16 | } 17 | 18 | return leapYear; 19 | 20 | } 21 | 22 | 23 | const randomYears = [2023,2024,2025,2028,2030]; 24 | const leapYear_Year = findLeapYear(randomYears); 25 | 26 | console.log("Array of leap year",leapYear_Year ); -------------------------------------------------------------------------------- /challanges1-to-72/problem49/problem49.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | You have an array [ 1, 9, 17, 22 ]. Add the all elements 4 | of this array and give output. Do this using `for loop` & 5 | `array.reduce()` method. 6 | 7 | problem provider : https://drive.google.com/file/d/1XcvIBe_rJlr6GY2rTnHlbIluTABXNhp7/view 8 | 9 | */ 10 | 11 | /* ============================ 12 | Using for loop 13 | =============================== */ 14 | 15 | const numbers = [ 1, 9, 17, 22 ]; 16 | let total = 0 ; 17 | 18 | /* -------Using Normal for loop---------*/ 19 | 20 | for(var i = 0; i < numbers.length; i++){ 21 | const number = numbers[i]; 22 | total = total + number; 23 | } 24 | 25 | console.log(total); 26 | 27 | /* -------Using for of loop---------*/ 28 | 29 | let total2 = 0 ; 30 | for( const number of numbers){ 31 | total2 = total2 + number; 32 | } 33 | 34 | console.log(total2); -------------------------------------------------------------------------------- /challanges1-to-72/problem27/problem27.js: -------------------------------------------------------------------------------- 1 | /* Write a function called odd_even() which takes an integer value and tells whether this value is even or odd. You need to do it in 4 ways: 2 | - Has return + Has parameter 3 | - No return + Has parameter */ 4 | 5 | 6 | 7 | // Has return+ Has parameter 8 | 9 | 10 | function odd_even(num){ 11 | if(num % 2 == 0){ 12 | 13 | return num + " is an even number."; 14 | } 15 | 16 | else{ 17 | return num + " is an odd number."; 18 | } 19 | }; 20 | 21 | var randomNum = odd_even(16); 22 | console.log(randomNum); 23 | 24 | 25 | // No return + Has parameter 26 | 27 | function odd_even(num){ 28 | if( num % 2 == 0){ 29 | console.log(num, " is an Even number."); 30 | } 31 | else{ 32 | console.log(num, " is an Odd number."); 33 | } 34 | } 35 | 36 | odd_even(50); 37 | 38 | -------------------------------------------------------------------------------- /challanges1-to-72/problem43/proble43.js: -------------------------------------------------------------------------------- 1 | /* Who is the tallest? 2 | Tom and his friends are participating in the "Who is the tallest?" competition. As per the name, the person with the highest height will be the winner. Can you find who is the tallest among Tom and all of his friends? 3 | 4 | **Input: The input line can have multiple integer numbers, xi (The height of ith friend in cm).** 5 | 6 | **Output: Print the height of the tallest friend (cm).** 7 | 8 | 1. Sample Input-1: 157 134 188 9 | - Sample Output-1: 188 10 | 2. Sample Input-2: 167 100 120 165 137 190 11 | - Sample Output-2: 190 */ 12 | 13 | 14 | 15 | const theTallestIs = (peoplesHeight) => { 16 | const tallest = Math.max(...peoplesHeight); 17 | return tallest; 18 | }; 19 | 20 | 21 | const heights = [167, 100, 120, 165, 137, 190]; 22 | const result = theTallestIs(heights); 23 | 24 | console.log(result); -------------------------------------------------------------------------------- /challanges1-to-72/problem47/problem47.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Write an arrow function where it will do the following:** 4 | 1. It will take two array inputs 5 | 2. Combine the two arrays and assign them in a new array 6 | 3. Find the maximum number from the new array and return the 7 | result 8 | 9 | Print the result. 10 | 11 | 12 | problem getting source : https://drive.google.com/file/d/1Ut8t4Ed8V-U0Axtz4nbIXJhmxvMEMUe9/view 13 | 14 | */ 15 | 16 | const findTheBiggestNumber = (arr1, arr2) => { 17 | const combinationOfTowArr = [...arr1, ...arr2]; 18 | const biggestNumberIs = Math.max(...combinationOfTowArr); 19 | 20 | return biggestNumberIs; 21 | }; 22 | 23 | 24 | const numberListOne = [10, 20, 30, 50, 512, 101375]; 25 | const numberListTwo = [60, 70, 80, 19, 100, 1375]; 26 | const result = findTheBiggestNumber(numberListOne, numberListTwo); 27 | console.log(result); 28 | -------------------------------------------------------------------------------- /challanges1-to-72/problem38/problem38.js: -------------------------------------------------------------------------------- 1 | //Calculate the average rate(%) of profit 2 | 3 | 4 | function averageRateOfProfit(profits, invest ){ 5 | let totalProfit = 0; 6 | for( let i = 0; i < profits.length; i++){ 7 | const index = i ; 8 | const profit = profits[index]; 9 | totalProfit = totalProfit + profit; 10 | } 11 | const averageProfit = totalProfit / profits.length; 12 | const averageInvest = invest / 2; 13 | const averageRateOfProfit = (averageProfit / averageInvest) * 100; 14 | const outputMessage = "Average Rate of profit is "+ averageRateOfProfit.toFixed(1)+"%"; 15 | return outputMessage; 16 | 17 | } 18 | 19 | 20 | 21 | const profitsList = [60000, 70000, 75000, 80000, 85000]; 22 | const totalInvest = 500000; 23 | const profitRate = averageRateOfProfit(profitsList, totalInvest ); 24 | 25 | console.log(profitRate); 26 | 27 | -------------------------------------------------------------------------------- /challanges1-to-72/problem53/problem53.md: -------------------------------------------------------------------------------- 1 | ## Practice Problem 53: `Access Object Values` 2 | 3 | ``` 4 | const user = { 5 | id: 1, 6 | name: "Leanne Graham", 7 | username: "Bret", 8 | email: "Sincere@april.biz", 9 | address: { 10 | street: "Kulas Light", 11 | suite: "Apt. 556", 12 | city: "Gwenborough", 13 | zipcode: "92998-3874", 14 | geo: { 15 | lat: "-37.3159", 16 | lng: "81.1496", 17 | }, 18 | }, 19 | phone: "1-770-736-8031 x56442", 20 | website: "hildegard.org", 21 | company: { 22 | name: "Romaguera-Crona", 23 | catchPhrase: "Multi-layered client-server neural-net", 24 | bs: "harness real-time e-markets", 25 | }, 26 | }; 27 | 28 | ``` 29 | 30 | ### Challenging 31 | 32 | - Console the value of `email` 33 | - Console the value of `address` 34 | - Console the value of `city` 35 | - Console the value of `lat` 36 | - Console the value of `company name` -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/13.Sleep/sleep.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Given a positive integer millis, write an asynchronous function that sleeps for millis milliseconds. It can resolve any value. 3 | 4 | Note that minor deviation from millis in the actual sleep duration is acceptable. 5 | 6 | 7 | 8 | Example 1: 9 | 10 | Input: millis = 100 11 | Output: 100 12 | Explanation: It should return a promise that resolves after 100ms. 13 | let t = Date.now(); 14 | sleep(100).then(() => { 15 | console.log(Date.now() - t); // 100 16 | }); 17 | Example 2: 18 | 19 | Input: millis = 200 20 | Output: 200 21 | Explanation: It should return a promise that resolves after 200ms. 22 | 23 | 24 | Constraints: 25 | 26 | 1 <= millis <= 1000 27 | 28 | 29 | */ 30 | 31 | 32 | 33 | async function sleep(mils: number): Promise { 34 | 35 | return new Promise(sleepDelay => { 36 | setTimeout(sleepDelay, mils); 37 | }); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /challanges1-to-72/problem56/problem56.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | let data = [ 4 | { 5 | pHeroCourses: { 6 | "course-x": "web development", 7 | }, 8 | }, 9 | 10 | { 11 | pHeroCourses: { 12 | "course-y": "phitron", 13 | }, 14 | }, 15 | 16 | { 17 | pHeroCourses: { 18 | "course-z": "acc", 19 | }, 20 | }, 21 | 22 | { 23 | pHeroCourses: { 24 | "course-xyz": "level-2", 25 | }, 26 | 27 | locationField: { 28 | "en-US": { 29 | lat: 19.28563, 30 | lon: 72.8691, 31 | }, 32 | }, 33 | }, 34 | ]; 35 | 36 | 37 | /* 38 | 39 | How will you get the output `[uses 2D matrix concept]` 40 | 41 | 1. level-2 42 | 2. 72.8621 43 | 44 | */ 45 | 46 | 47 | const firstOutput = data[3].pHeroCourses['course-xyz']; 48 | console.log(firstOutput); 49 | 50 | const secondOutput = data[3].locationField['en-US'].lon; 51 | console.log(secondOutput); 52 | -------------------------------------------------------------------------------- /challanges1-to-72/problem68/problem68.js: -------------------------------------------------------------------------------- 1 | /* 2 | Create a function that takes a sorted array of numbers and a target value as input. The function should find two numbers in the array that add up to the target value. Return an array containing the indices of the two numbers. 3 | 4 | Example Input: ([1, 3, 6, 8, 11, 15], 9) Example Output: [1, 2] (numbers at indices 1 and 2: 3 + 6 = 9) 5 | 6 | */ 7 | 8 | const twoIndices = (arr, target) => { 9 | const allNumbers = {}; 10 | 11 | for (let i = 0; i < arr.length; i++) { 12 | const firstNum = arr[i]; 13 | const secondNum = target - firstNum; 14 | if (allNumbers.hasOwnProperty(secondNum)) { 15 | const firstIndex = allNumbers[secondNum]; 16 | return [firstIndex, i]; 17 | } 18 | 19 | allNumbers[firstNum] = i; 20 | } 21 | 22 | return []; 23 | } 24 | 25 | // Example usage: 26 | console.log(twoIndices([1, 3, 6, 8, 11, 15], 9)); -------------------------------------------------------------------------------- /challanges1-to-72/problem65/problme65.js: -------------------------------------------------------------------------------- 1 | /* : Create a function that takes a string as input and returns the reversed version of the string without using the built-in reverse() method. */ 2 | 3 | /* Example Input: "hello world" Example Output: "dlrow olleh" */ 4 | 5 | /* ---------------------------- 6 | Solution One: 7 | ------------------------------- */ 8 | 9 | function textReverser(text){ 10 | 11 | let reverseText = ''; 12 | 13 | for(let i = text.length - 1; i >= 0; i--){ 14 | const letter = text[i]; 15 | reverseText = reverseText + letter; 16 | } 17 | 18 | return reverseText; 19 | } 20 | 21 | console.log(textReverser("hello world")); 22 | 23 | 24 | /* ---------------------------- 25 | Solution Two: 26 | ------------------------------- */ 27 | 28 | const stringReverser = text => text.split('').reduce((previous, present) => present + previous, '' ); 29 | 30 | console.log(stringReverser("hello world")); -------------------------------------------------------------------------------- /challanges1-to-72/problem58/problem58.js: -------------------------------------------------------------------------------- 1 | let students = { 2 | 2222: { 3 | name: "Jack", 4 | section: "C", 5 | class: "IX", 6 | address: { 7 | "building no": 12, 8 | street: "St. Jonson", 9 | city: "Petersburg", 10 | country: "UK", 11 | }, 12 | }, 13 | 3333: { 14 | name: "Herry", 15 | section: "D", 16 | class: "X", 17 | address: { 18 | "building no": 85, 19 | street: "DC road", 20 | city: "Kachukhet", 21 | country: "Bangladesh", 22 | }, 23 | }, 24 | }; 25 | 26 | 27 | 28 | 29 | 30 | /*========================================= 31 | Display: 32 | 1. Petersbur 33 | 2. Herry 34 | ============================================ */ 35 | 36 | 37 | const firstDisplayValue = students['2222']['address']['city']; 38 | console.log(firstDisplayValue); 39 | 40 | 41 | const secondDisplayValue = students['3333']['name']; 42 | console.log(secondDisplayValue); 43 | 44 | -------------------------------------------------------------------------------- /challanges1-to-72/problem69/problme69.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Implement a simple JavaScript calculator. The calculator should take two numbers and an operator (+, -, *, /) as input and return the result of the operation. 4 | 5 | 6 | */ 7 | 8 | const JsCalculator = (num1, num2, operator) => { 9 | 10 | if( operator === '+'){ 11 | return num1 + num2 ; 12 | } 13 | else if( operator === '-'){ 14 | return num1 - num2; 15 | } 16 | else if( operator === '*'){ 17 | return num1 * num2; 18 | } 19 | else if( operator === '/'){ 20 | if (num2 === 0) { 21 | return "Error: Division by zero is not allowed."; 22 | } 23 | return num1 / num2 ; 24 | } 25 | else if ( operator === '%'){ 26 | return num1 % num2 ; 27 | } 28 | else{ 29 | return 'Error: Please inter valid number and mathematical operator.'; 30 | } 31 | }; 32 | 33 | const result = JsCalculator(400, 200, '+'); 34 | console.log(result); -------------------------------------------------------------------------------- /challanges1-to-72/problem45/problem45.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | ## Practice Problem 45 4 | 5 | **Write an arrow function where it will do the following:** 6 | 7 | 1. It will take an array where the array elements will be the 8 | name of your friends 9 | 10 | 2. Check if the length of each element is even, push elements 11 | with even length to a new array and return the result 12 | Print the result. 13 | 14 | 15 | 16 | */ 17 | 18 | 19 | const findEven = nameList => { 20 | 21 | const evenLengthName = []; 22 | for(let i = 0; i < nameList.length; i++){ 23 | 24 | const friendName = nameList[i]; 25 | if(friendName.length % 2 == 0){ 26 | evenLengthName.push(friendName); 27 | } 28 | } 29 | 30 | return evenLengthName; 31 | } 32 | 33 | 34 | const friendsName = ["Shourav", "Nirob", "Alal", "Jala", "Ashim", "Shipta", "Pritom", "Arko", "Alu"]; 35 | 36 | const evenLengthFriendsNameList = findEven(friendsName); 37 | console.log(evenLengthFriendsNameList); -------------------------------------------------------------------------------- /challanges1-to-72/problem60/problem60.js: -------------------------------------------------------------------------------- 1 | const studentData = [ 2 | { 3 | class: 10, 4 | details: [ 5 | { 6 | studentId: "1", 7 | gradingDetails: [{ grade: "A" }], 8 | }, 9 | { 10 | studentId: "2", 11 | gradingDetails: [{ grade: "B" }], 12 | }, 13 | ], 14 | }, 15 | { 16 | class: 11, 17 | details: [ 18 | { 19 | studentId: 3, 20 | gradingDetails: [{ grade: "B" }], 21 | }, 22 | { 23 | studentId: 4, 24 | gradingDetails: [{ grade: "D" }], 25 | }, 26 | ], 27 | }, 28 | ]; 29 | 30 | /* ===========Display B , D =========== */ 31 | 32 | 33 | const displayB10 = studentData[0].details[1].gradingDetails[0].grade; 34 | console.log(displayB10); 35 | 36 | const displayB11 = studentData[1].details[0].gradingDetails[0].grade; 37 | console.log(displayB11); 38 | 39 | const displayD = studentData[1].details[1].gradingDetails[0].grade; 40 | 41 | console.log(displayD); 42 | 43 | -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/9.Return_Length_of_Arguments_Passed/Return_Length_of_Arguments_Passed.ts: -------------------------------------------------------------------------------- 1 | /* 2 | 2703. Return Length of Arguments Passed 3 | 4 | 5 | Write a function argumentsLength that returns the count of arguments passed to it. 6 | 7 | 8 | Example 1: 9 | 10 | Input: args = [5] 11 | Output: 1 12 | Explanation: 13 | argumentsLength(5); // 1 14 | 15 | One value was passed to the function so it should return 1. 16 | Example 2: 17 | 18 | Input: args = [{}, null, "3"] 19 | Output: 3 20 | Explanation: 21 | argumentsLength({}, null, "3"); // 3 22 | 23 | Three values were passed to the function so it should return 3. 24 | 25 | 26 | Constraints: 27 | 28 | args is a valid JSON array 29 | 0 <= args.length <= 100 30 | 31 | */ 32 | 33 | 34 | type JSONValue = null | boolean | number | string | JSONValue[] | { [key: string]: JSONValue }; 35 | 36 | function argumentsLength(...args: JSONValue[]): number { 37 | 38 | return args.length; 39 | }; 40 | 41 | /** 42 | * argumentsLength(1, 2, 3); // 3 43 | */ -------------------------------------------------------------------------------- /challanges1-to-72/problem6/problem6.js: -------------------------------------------------------------------------------- 1 | 2 | /* তাড়াহুড়া করে স্কুলের জন্য বের হচ্ছ কিন্তু রাস্তা পার হওয়ার সময় দেখলে, ট্রাফিক সিগন্যাল লাল রং। এই অবস্থায় যদি তুমি রাস্তা পার হওয়ার চেষ্টা কর, তাহলে ডেঞ্জার হতে পারে। যদি হলুদ রং হয় তাহলে তোমার থেমে যাওয়া উচিত। আর যদি ট্রাফিক সিগন্যাল গ্রিন হয় তাহলে তোমার রাস্তা পার হওয়া উচিত। তাই একটা কোড লিখে ফেলো। যেখানে আমরা signal নামে একটা ভেরিয়েবল থাকবে। সেটার মান green, yellow বা red হতে পারে। সেই অনুসারে ডিফারেন্ট ডিফারেন্ট কাজ হবে। তো, সেই কোড ফটাফট লিখে ফেলো। 3 | */ 4 | 5 | //Value Red 6 | var signal = "red"; 7 | //Value Yellow 8 | /* var signal = "yellow"; */ 9 | //Value Green 10 | /* var signal = "green"; */ 11 | 12 | 13 | if(signal == "red" ){ 14 | console.log("Danger!💀 Danger!💀 Please stop🛑🛑. It's not the time for crossing the road."); 15 | } 16 | 17 | else if(signal == "yellow"){ 18 | console.log("Please stop🤚🤚. Wait for green."); 19 | } 20 | 21 | else if(signal == "green"){ 22 | console.log("Go ahead. It's green it's safe for crossing the road."); 23 | } 24 | -------------------------------------------------------------------------------- /challanges1-to-72/problem62/problem62.js: -------------------------------------------------------------------------------- 1 | /* ===================================================================== 2 | ------ Programme for calculating Total vowels and consonants -------- 3 | ===================================================================== */ 4 | 5 | const countVowelsAndConsonants = textInput => { 6 | const allLetters = textInput.toLowerCase(); 7 | const vowels = 'aeiou'; 8 | let vowelsCount = 0 ; 9 | let consonantsCount = 0; 10 | 11 | for ( let i = 0; i < allLetters.length; i++){ 12 | let letter = allLetters[i]; 13 | 14 | if(/[a-z]/.test(letter)){ 15 | 16 | if(vowels.includes(letter)){ 17 | vowelsCount++; 18 | } 19 | else{ 20 | consonantsCount++; 21 | } 22 | } 23 | 24 | }; 25 | return {yourInput: textInput, totalVowels: vowelsCount, totalConsonants: consonantsCount}; 26 | }; 27 | 28 | console.log( countVowelsAndConsonants("developer.shourav1@gmail.com")); -------------------------------------------------------------------------------- /challanges1-to-72/problem14/problme14.js: -------------------------------------------------------------------------------- 1 | /* Task 1. Print the numbers 58 to 98 2 | 3 | Task 2. Print all the even numbers between 412 to 456 4 | 5 | Task 3. Print all the odd numbers between 581 to 623 */ 6 | 7 | 8 | // Task 1: Print the numbers 58 to 98 9 | 10 | /* for( var i = 58; i <= 98; i++){ 11 | console.log(i); 12 | } */ 13 | 14 | // Task 2: Print all the even numbers between 412 to 456 15 | 16 | 17 | // method a 18 | /* var num = 412; 19 | while ( num <= 456) { 20 | console.log(num); 21 | num+=2; 22 | 23 | } */ 24 | 25 | // method b 26 | 27 | var num = 412; 28 | 29 | while( num <= 456){ 30 | if( num % 2 == 0){ 31 | console.log(num); 32 | } 33 | num++; 34 | } 35 | 36 | // Task 3: Print all the odd numbers between 581 to 623 37 | 38 | // method a 39 | 40 | /* for( var i = 581; i <= 623; i+=2){ 41 | console.log(i); 42 | } 43 | */ 44 | // method b 45 | 46 | for( var i = 581; i <= 623; i++){ 47 | if(i % 2 == 0){ 48 | continue; 49 | } 50 | console.log(i); 51 | } -------------------------------------------------------------------------------- /challanges1-to-72/problem59/problem59.js: -------------------------------------------------------------------------------- 1 | let instructor = { 2 | name: "Jhankar Mahbub", 3 | entrepreneur: true, 4 | additionalData: { 5 | writer: true, 6 | favoriteHobbies: ["travelling", "Coding"], 7 | books: ["programming er bolod to bos", "programming er coddogosti"], 8 | moreDetails: { 9 | favoriteBasketballTeam: "XYZ", 10 | isYoungest: true, 11 | hometown: { 12 | city: "ABC", 13 | state: "VW", 14 | }, 15 | countriesLivedIn: ["Bangladesh", "New York"], 16 | }, 17 | }, 18 | }; 19 | 20 | 21 | /* 22 | How will you display 23 | - programming er coddogosti 24 | - VW 25 | - Bangladesh 26 | 27 | */ 28 | 29 | 30 | const firstDisplayItem = instructor['additionalData']['books'][1]; 31 | console.log(firstDisplayItem); 32 | 33 | const secondDisplayItem = instructor.additionalData.moreDetails.hometown.state; 34 | console.log(secondDisplayItem); 35 | 36 | const thirdDisplayItem = instructor['additionalData']['moreDetails']['countriesLivedIn'][0]; 37 | console.log(thirdDisplayItem); 38 | 39 | -------------------------------------------------------------------------------- /challanges1-to-72/problem39/problem39.js: -------------------------------------------------------------------------------- 1 | /* ## Can you find out who will get the delicious cake? 2 | ### (Part 1) 3 | Jim is a meritorious student. He secures first place in his class all the time. 4 | This year, Dela has joined his class. She was also a topper at her previous school. 5 | On the day of result publication, the teacher comes into the class with a delicious cake and says that "Jim & Dela, whoever is the topper, will get this tasty cake." Can you find out who will get this cake? 6 | 7 | **Input: The input line has two values, m (The marks Jim has got) and n (The marks Dela has got).** 8 | **Output: Print the name of the topper.** 9 | 10 | 1. Sample Input-1: 84 75 11 | - Sample Output-1: Jim 12 | 13 | 14 | 2. Sample Input-2: 69 97 15 | - Sample Output-2: Dela */ 16 | 17 | 18 | 19 | function findingTopper(m,n){ 20 | if( m > n){ 21 | return "Jim"; 22 | } 23 | 24 | else{ 25 | return "Dela" 26 | } 27 | 28 | }; 29 | 30 | 31 | const jimsMarks = 69; 32 | const delasMarks = 97; 33 | 34 | const theCakeWillGet = findingTopper(jimsMarks, delasMarks); 35 | console.log(theCakeWillGet); -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/1.Create-Hello-World-Function/problem.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | 4 | Write a function createHelloWorld. It should return a new function that always returns "Hello World". 5 | 6 | 7 | Example 1: 8 | 9 | Input: args = [] 10 | Output: "Hello World" 11 | Explanation: 12 | const f = createHelloWorld(); 13 | f(); // "Hello World" 14 | 15 | The function returned by createHelloWorld should always return "Hello World". 16 | Example 2: 17 | 18 | Input: args = [{},null,42] 19 | Output: "Hello World" 20 | Explanation: 21 | const f = createHelloWorld(); 22 | f({}, null, 42); // "Hello World" 23 | 24 | Any arguments could be passed to the function but it should still always return "Hello World". 25 | 26 | 27 | Constraints: 28 | 29 | 0 <= args.length <= 10 30 | 31 | 32 | 33 | */ 34 | 35 | 36 | /* -------------------Solution---------------------- */ 37 | 38 | /* @return {Function} 39 | */ 40 | var createHelloWorld = function () { 41 | 42 | return function (...args) { 43 | return "Hello World"; 44 | } 45 | }; 46 | 47 | const f = createHelloWorld(); 48 | console.log(f());; // "Hello World" 49 | -------------------------------------------------------------------------------- /challanges1-to-72/problem66/problme66.js: -------------------------------------------------------------------------------- 1 | /* 2 | Create a function that takes an array of numbers as input and returns the sum of all positive numbers in the array. 3 | 4 | Example Input: [2, -5, 10, -3, 7] Example Output: 19 */ 5 | 6 | /* ---------------------------------- 7 | Solution One using for loop: 8 | ------------------------------------- */ 9 | 10 | function calculatePositiveNumbers(arrayOfNumbers){ 11 | 12 | let total = 0; 13 | for( let i = 0; i < arrayOfNumbers.length; i++){ 14 | if(arrayOfNumbers[i] > 0){ 15 | total = total + arrayOfNumbers[i]; 16 | } 17 | } 18 | 19 | return total; 20 | }; 21 | 22 | console.log(calculatePositiveNumbers([2, -5, 10, -3, 7])); 23 | 24 | /* ------------------------------------------ 25 | Solution Two using es6 array method: 26 | ------------------------------------------------ */ 27 | 28 | const totalOfPositiveNumbers = arrayOfNumbers => { 29 | const positiveNumbers = arrayOfNumbers.filter( numbers => numbers > 0); 30 | const total = positiveNumbers.reduce((previous, present) => previous + present , 0); 31 | return total; 32 | } 33 | 34 | console.log(totalOfPositiveNumbers([2, -5, 10, -3, 7])); -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/2.Counter/Counter.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Given an integer n, return a counter function. This counter function initially returns n and then returns 1 more than the previous value every subsequent time it is called (n, n + 1, n + 2, etc). 4 | 5 | 6 | 7 | Example 1: 8 | 9 | Input: 10 | n = 10 11 | ["call","call","call"] 12 | Output: [10,11,12] 13 | Explanation: 14 | counter() = 10 // The first time counter() is called, it returns n. 15 | counter() = 11 // Returns 1 more than the previous time. 16 | counter() = 12 // Returns 1 more than the previous time. 17 | 18 | 19 | 20 | Example 2: 21 | 22 | Input: 23 | n = -2 24 | ["call","call","call","call","call"] 25 | Output: [-2,-1,0,1,2] 26 | Explanation: counter() initially returns -2. Then increases after each sebsequent call. 27 | 28 | 29 | Constraints: 30 | 31 | -1000 <= n <= 1000 32 | 0 <= calls.length <= 1000 33 | calls[i] === "call" 34 | 35 | 36 | 37 | 38 | 39 | /** 40 | * @param {number} n 41 | * @return {Function} counter 42 | */ 43 | 44 | 45 | var createCounter = function (n) { 46 | return function () { 47 | return n++; 48 | }; 49 | }; 50 | 51 | const counter = createCounter(10) 52 | console.log(counter()); // 10 53 | 54 | -------------------------------------------------------------------------------- /challanges1-to-72/problem44/problem44.js: -------------------------------------------------------------------------------- 1 | /* ## Practice Problem 44 2 | 3 | 1. Write an arrow function that will take **3** parameters, will multiply 4 | the parameters and will return the result. 5 | 6 | 2. Write the following sentence in **three lines** and print the result: 7 | **I am a web developer. I love to code. I love to eat biryani.** 8 | 9 | 3. Write an arrow function that will take **2** parameters: One parameter 10 | will come from you and the other parameter will be a default 11 | parameter. Add these two parameters and return the result. 12 | 13 | 14 | 15 | problem source: https://drive.google.com/file/d/1Ut8t4Ed8V-U0Axtz4nbIXJhmxvMEMUe9/view?usp=sharing */ 16 | 17 | 18 | 19 | 20 | /* Task One: */ 21 | 22 | const multiplier = ( num1, num2, num3) => num1 * num2 * num3 ; 23 | 24 | 25 | const resultOfThreeParamsMultiply = multiplier(10, 20, 30); 26 | console.log(resultOfThreeParamsMultiply); 27 | 28 | 29 | 30 | /* Task Two: */ 31 | 32 | const aboutDeveloper = `I am a web developer. 33 | I love to code. 34 | I love to eat biryani.`; 35 | 36 | console.log(aboutDeveloper); 37 | 38 | 39 | /* Task Three: */ 40 | 41 | const sum = (a, b = 375) => a + b ; 42 | 43 | const totalOf = sum(1000); 44 | console.log(totalOf); 45 | 46 | -------------------------------------------------------------------------------- /challanges1-to-72/problem42/problem42.js: -------------------------------------------------------------------------------- 1 | /* ## Find the lowest price product */ 2 | 3 | 4 | 5 | function findTheLowest(product1, product2, product3, product4){ 6 | const lowestPrice = Math.min(product1, product2, product3, product4); 7 | 8 | if(product1 === lowestPrice){ 9 | const outputMassage1 = "The lowest price product is Phone. " + "And it's price is " + product1; 10 | return outputMassage1; 11 | } 12 | 13 | else if(product2 === lowestPrice){ 14 | const outputMassage2 = "The lowest price product is Computer. " + "And it's price is " + product2; 15 | return outputMassage2; 16 | } 17 | 18 | else if(product3 === lowestPrice){ 19 | const outputMassage3 = "The lowest price product is Tv. " + "And it's price is " + product3; 20 | return outputMassage3; 21 | } 22 | 23 | else{ 24 | const outputMassage4 = "The lowest price product is Fridge. " + "And it's price is " + product4; 25 | return outputMassage4; 26 | } 27 | 28 | 29 | }; 30 | 31 | 32 | 33 | const phone = 120000; 34 | const computer = 65000; 35 | const tv = 20000; 36 | const fridge = 27000; 37 | 38 | const lowestPriceProduct = findTheLowest(phone, computer, tv, fridge); 39 | console.log(lowestPriceProduct); -------------------------------------------------------------------------------- /challanges1-to-72/problem55/problem55.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /* How will you access Sophia’s secondary school location? */ 5 | 6 | let data = { 7 | Sophia: { 8 | id: 33, 9 | study: [ 10 | { 11 | primary: [ 12 | { school_name: "ABC primary school" }, 13 | { location: "Peters burg" }, 14 | ], 15 | }, 16 | { 17 | secondary: [ 18 | { school_name: "ABC secondary school" }, 19 | 20 | { location: "St Lorence" }, 21 | ], 22 | }, 23 | ], 24 | }, 25 | 26 | }; 27 | 28 | /* ================================================== 29 | Method One: Using Dot(.) Notation 30 | ===================================================== */ 31 | const secondarySchoolLocation1 = data.Sophia.study[1].secondary[1].location; 32 | 33 | console.log(secondarySchoolLocation1); 34 | /* ================================================== 35 | Method Two: Using Bracket[] Notation 36 | ===================================================== */ 37 | 38 | const secondarySchoolLocation2 = data['Sophia']['study'][1]['secondary'][1]['location']; 39 | console.log(secondarySchoolLocation2); 40 | -------------------------------------------------------------------------------- /challanges1-to-72/problem70/problme70.js: -------------------------------------------------------------------------------- 1 | /* Create a program that generates a random password of a specified length. The password should include a mix of uppercase letters, lowercase letters, numbers, and special characters. */ 2 | 3 | const randomPasswordGenerator = length => { 4 | const uppercaseChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; 5 | const lowercaseChars = 'abcdefghijklmnopqrstuvwxyz'; 6 | const numberChars = '0123456789'; 7 | const specialChars = '!@#$%^&*()_-+=<>?/{}~'; 8 | 9 | const allChars = uppercaseChars + numberChars + lowercaseChars + specialChars; 10 | 11 | let password = ''; 12 | 13 | if(length < 4){ 14 | return 'Error: password length should be 4 characters or above.'; 15 | 16 | } 17 | 18 | while (true) { 19 | for (let i = 0; i < length; i++) { 20 | const randomIndex = Math.ceil(Math.random() * allChars.length); 21 | password += allChars.charAt(randomIndex); 22 | } 23 | 24 | if (/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_\-+=<>?/{}~])/.test(password)) { 25 | break; 26 | } 27 | 28 | password = ''; 29 | } 30 | 31 | return password; 32 | } 33 | 34 | const passwordLength = 10; 35 | const randomPassword = randomPasswordGenerator(passwordLength); 36 | console.log(randomPassword); 37 | -------------------------------------------------------------------------------- /challanges1-to-72/problem53/problem53.js: -------------------------------------------------------------------------------- 1 | /* 2 | ### Challenging 3 | 4 | Console the value of email 5 | Console the value of address 6 | Console the value of city 7 | Console the value of lat 8 | Console the value of company name 9 | */ 10 | 11 | 12 | const user = { 13 | id: 1, 14 | name: "Leanne Graham", 15 | username: "Bret", 16 | email: "Sincere@april.biz", 17 | address: { 18 | street: "Kulas Light", 19 | suite: "Apt. 556", 20 | city: "Gwenborough", 21 | zipcode: "92998-3874", 22 | geo: { 23 | lat: "-37.3159", 24 | lng: "81.1496", 25 | }, 26 | }, 27 | phone: "1-770-736-8031 x56442", 28 | website: "hildegard.org", 29 | company: { 30 | name: "Romaguera-Crona", 31 | catchPhrase: "Multi-layered client-server neural-net", 32 | bs: "harness real-time e-markets", 33 | }, 34 | }; 35 | 36 | const emailOfUser = user.email; 37 | const userAddres = user.address; 38 | const userCity = user.address.city; 39 | const userGeoLat = user['address']['geo']['lat']; 40 | const userCompany = user.company['name']; 41 | 42 | console.log(userAddres); 43 | const totalOutput = ` 44 | 1. User email is ${emailOfUser} 45 | 2. User address is ${userAddres} 46 | 3. User city is ${userCity} 47 | 4. User lat is ${userGeoLat} 48 | 5. User company is ${userCompany} 49 | 50 | `; 51 | 52 | 53 | console.log(totalOutput); -------------------------------------------------------------------------------- /challanges1-to-72/problem50/problem50.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | const people = [ 4 | {name: 'Meena', age: 20}, 5 | {name: 'Rina', age: 15}, 6 | {name: 'Suchorita', age: 22} 7 | ]; 8 | 9 | 1. Challenging Follow above array of objects. So, you have 3 objects as 10 | array element. Can you find out the total sum from here? 11 | 12 | 20 + 15 + 22 = 57 . The output will be 57 13 | 14 | What are you thinking? Yeah! Do it with for loop. I know you can do it. 15 | But! Wait !! Wait !!! Do the same task using array.reduce() method. 16 | 17 | problem provider : https://drive.google.com/file/d/1XcvIBe_rJlr6GY2rTnHlbIluTABXNhp7/view 18 | 19 | */ 20 | 21 | const people = [ 22 | {name: 'Meena', age: 20}, 23 | {name: 'Rina', age: 15}, 24 | {name: 'Suchorita', age: 22} 25 | ]; 26 | 27 | /* =================================== 28 | First task (using for loop) 29 | ======================================*/ 30 | let sumOfAge = 0 ; 31 | for( let i = 0; i < people.length; i++){ 32 | const age = people[i].age; 33 | sumOfAge = sumOfAge + age ; 34 | }; 35 | 36 | console.log(sumOfAge); 37 | 38 | /* ================================================ 39 | Final task using for reduce() 40 | ===================================================*/ 41 | const allAges = people.map(x => x.age); 42 | const ageTotal = allAges.reduce((previoustotal, presentValue) => previoustotal + presentValue,0); 43 | 44 | 45 | console.log(ageTotal); -------------------------------------------------------------------------------- /challanges1-to-72/problem28/problem28.js: -------------------------------------------------------------------------------- 1 | /* You are in a hurry to go to your school on time. But when you are crossing the road, the traffic signal is red coloured. 2 | In this situation, if you try to cross the road, you may be in danger. 3 | If you notice a yellow coloured traffic signal, you should stop. 4 | If you notice a green coloured traffic signal, you should cross the road. 5 | So write a JS code, where there is a variable called signal. 6 | Its value can be green, yellow or red & we will get different activities as output depending on the variable. So, hurry up */ 7 | 8 | 9 | // Solving the problem with if else conditions 10 | 11 | var signal = "yellow"; 12 | 13 | if( signal == "red"){ 14 | console.log("💀⚡💀Don't move it's Dangerous!! Please wait for Green."); 15 | } 16 | 17 | else if ( signal == "yellow"){ 18 | console.log("⚠️⚠️ Don't Crass the road it's not safe!! Wait for Green."); 19 | } 20 | 21 | else{ 22 | console.log("🟢🟢Now it's safe . You can go now."); 23 | } 24 | 25 | // Solving the problem with switch 26 | 27 | switch(signal){ 28 | case "red": 29 | console.log("💀⚡💀Don't move it's Dangerous!! Please wait for Green."); 30 | break; 31 | case "yellow": 32 | console.log("⚠️⚠️ Don't Crass the road it's not safe!! Wait for Green."); 33 | break; 34 | default : 35 | console.log("🟢🟢Now it's safe . You can go now."); 36 | 37 | }; 38 | 39 | 40 | -------------------------------------------------------------------------------- /challanges1-to-72/problem40/problem40.js: -------------------------------------------------------------------------------- 1 | /* Can you find out who will get the delicious cake? 2 | (Part II) 3 | This year, not only Jim & Dela but also Chinku are doing hard work to secure the first position. Can you find out who will get the delicious cake? 4 | 5 | **Input: The input line has three values, x (The marks Jim has got), y (The marks Dela has got) and z (The marks Chinku has got)** 6 | 7 | **Output: Print the name of the topper.** 8 | 9 | 1. Sample Input-1: 84 99 77 10 | - Sample Output-1: Dela 11 | 12 | 2. Sample Input-2: 69 97 99 13 | - Sample Output-2: Chinku */ 14 | 15 | 16 | 17 | function findingTopper(x, y, z){ 18 | if((typeof x === "number") && (typeof y === "number") && (typeof y === "number") ){ 19 | if ( x > y && x > z) { 20 | const cakeWinner = "Jim"; 21 | return cakeWinner; 22 | } 23 | 24 | else if( y > x && y > z){ 25 | const cakeWinner = "Dela"; 26 | return cakeWinner; 27 | } 28 | 29 | else{ 30 | const cakeWinner = "Chinku"; 31 | return cakeWinner; 32 | } 33 | 34 | } 35 | 36 | else{ 37 | const errorMassage = "Please inter number value (marks)"; 38 | return errorMassage; 39 | } 40 | 41 | }; 42 | 43 | 44 | const jimsMarks = 69; 45 | const delasMarks = 97; 46 | const chinkusMarks = 99; 47 | 48 | const theCakeWillGet = findingTopper(jimsMarks, delasMarks, chinkusMarks); 49 | console.log(theCakeWillGet); -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/12.Add_Two_Promises/Add_Two_Promises.ts: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Given two promises promise1 and promise2, return a new promise. promise1 and promise2 will both resolve with a number. The returned promise should resolve with the sum of the two numbers. 4 | 5 | 6 | Example 1: 7 | 8 | Input: 9 | promise1 = new Promise(resolve => setTimeout(() => resolve(2), 20)), 10 | promise2 = new Promise(resolve => setTimeout(() => resolve(5), 60)) 11 | Output: 7 12 | Explanation: The two input promises resolve with the values of 2 and 5 respectively. The returned promise should resolve with a value of 2 + 5 = 7. The time the returned promise resolves is not judged for this problem. 13 | Example 2: 14 | 15 | Input: 16 | promise1 = new Promise(resolve => setTimeout(() => resolve(10), 50)), 17 | promise2 = new Promise(resolve => setTimeout(() => resolve(-12), 30)) 18 | Output: -2 19 | Explanation: The two input promises resolve with the values of 10 and -12 respectively. The returned promise should resolve with a value of 10 + -12 = -2. 20 | 21 | 22 | Constraints: 23 | 24 | promise1 and promise2 are promises that resolve with a number 25 | 26 | 27 | 28 | 29 | 30 | */ 31 | 32 | 33 | 34 | type P = Promise 35 | 36 | async function addTwoPromises(promise1: P, promise2: P): P { 37 | const [res1, res2] = await Promise.all([promise1, promise2]); 38 | return res1 + res2; 39 | }; 40 | 41 | /** 42 | * addTwoPromises(Promise.resolve(2), Promise.resolve(2)) 43 | * .then(console.log); // 4 44 | */ -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/5.Apply_Transform_Over_Each_Element_in_Array/arrayTransform.ts: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | 4 | 5 | Apply Transform Over Each Element in Array 6 | 7 | Given an integer array arr and a mapping function fn, return a new array with a transformation applied to each element. 8 | 9 | The returned array should be created such that returnedArray[i] = fn(arr[i], i). 10 | 11 | Please solve it without the built-in Array.map method. 12 | 13 | 14 | 15 | Example 1: 16 | 17 | Input: arr = [1,2,3], fn = function plusone(n) { return n + 1; } 18 | Output: [2,3,4] 19 | Explanation: 20 | const newArray = map(arr, plusone); // [2,3,4] 21 | The function increases each value in the array by one. 22 | Example 2: 23 | 24 | Input: arr = [1,2,3], fn = function plusI(n, i) { return n + i; } 25 | Output: [1,3,5] 26 | Explanation: The function increases each value by the index it resides in. 27 | Example 3: 28 | 29 | Input: arr = [10,20,30], fn = function constant() { return 42; } 30 | Output: [42,42,42] 31 | Explanation: The function always returns 42. 32 | 33 | 34 | Constraints: 35 | 36 | 0 <= arr.length <= 1000 37 | -109 <= arr[i] <= 109 38 | fn returns an integer. 39 | 40 | 41 | 42 | */ 43 | 44 | 45 | function map(arr: number[], fn: (n: number, i: number) => number): number[] { 46 | const arr2: number[] = []; 47 | 48 | for (let i = 0; i < arr.length; i++) { 49 | const ele: number = fn(arr[i], i); 50 | arr2.push(ele); 51 | } 52 | 53 | return arr2; 54 | }; 55 | 56 | const namArr: number[] = [1, 2, 3]; 57 | const calFn = (n: number, i: number): number => { 58 | return n + i; 59 | }; -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/8.Function_Composition/Function_Composition.ts: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Given an array of functions [f1, f2, f3, ..., fn], return a new function fn that is the function composition of the array of functions. 4 | 5 | The function composition of [f(x), g(x), h(x)] is fn(x) = f(g(h(x))). 6 | 7 | The function composition of an empty list of functions is the identity function f(x) = x. 8 | 9 | You may assume each function in the array accepts one integer as input and returns one integer as output. 10 | 11 | 12 | 13 | Example 1: 14 | 15 | Input: functions = [x => x + 1, x => x * x, x => 2 * x], x = 4 16 | Output: 65 17 | Explanation: 18 | Evaluating from right to left ... 19 | Starting with x = 4. 20 | 2 * (4) = 8 21 | (8) * (8) = 64 22 | (64) + 1 = 65 23 | Example 2: 24 | 25 | Input: functions = [x => 10 * x, x => 10 * x, x => 10 * x], x = 1 26 | Output: 1000 27 | Explanation: 28 | Evaluating from right to left ... 29 | 10 * (1) = 10 30 | 10 * (10) = 100 31 | 10 * (100) = 1000 32 | Example 3: 33 | 34 | Input: functions = [], x = 42 35 | Output: 42 36 | Explanation: 37 | The composition of zero functions is the identity function 38 | 39 | 40 | Constraints: 41 | 42 | -1000 <= x <= 1000 43 | 0 <= functions.length <= 1000 44 | all functions accept and return a single integer 45 | 46 | 47 | */ 48 | 49 | 50 | 51 | type F = (x: number) => number; 52 | 53 | function compose(funArr: F[]): F { 54 | return function(x): number { 55 | return funArr.reduceRight((acc, curr) => curr(acc), x) 56 | } 57 | }; 58 | 59 | /** 60 | * const fn = compose([x => x + 1, x => 2 * x]) 61 | * fn(4) // 9 62 | */ -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/6.Filter_Elements_from_Array/Filter_Elements_from_Array.ts: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | 4 | 5 | Given an integer array arr and a filtering function fn, return a filtered array filteredArr. 6 | 7 | The fn function takes one or two arguments: 8 | 9 | arr[i] - number from the arr 10 | i - index of arr[i] 11 | filteredArr should only contain the elements from the arr for which the expression fn(arr[i], i) evaluates to a truthy value. A truthy value is a value where Boolean(value) returns true. 12 | 13 | Please solve it without the built-in Array.filter method. 14 | 15 | 16 | 17 | Example 1: 18 | 19 | Input: arr = [0,10,20,30], fn = function greaterThan10(n) { return n > 10; } 20 | Output: [20,30] 21 | Explanation: 22 | const newArray = filter(arr, fn); // [20, 30] 23 | The function filters out values that are not greater than 10 24 | Example 2: 25 | 26 | Input: arr = [1,2,3], fn = function firstIndex(n, i) { return i === 0; } 27 | Output: [1] 28 | Explanation: 29 | fn can also accept the index of each element 30 | In this case, the function removes elements not at index 0 31 | Example 3: 32 | 33 | Input: arr = [-2,-1,0,1,2], fn = function plusOne(n) { return n + 1 } 34 | Output: [-2,0,1,2] 35 | Explanation: 36 | Falsey values such as 0 should be filtered out 37 | 38 | 39 | Constraints: 40 | 41 | 0 <= arr.length <= 1000 42 | -109 <= arr[i] <= 109 43 | 44 | 45 | 46 | 47 | 48 | */ 49 | 50 | 51 | 52 | type Fn = (ele: T, idx?: number, arr?:T[]) => boolean 53 | 54 | function filter(arr: T[], fn: Fn) :T[] { 55 | const finalArr: T[] = []; 56 | 57 | for(let i = 0; i < arr.length; i++) { 58 | const item = fn(arr[i], i); 59 | if (item) { 60 | finalArr.push(arr[i]); 61 | } 62 | } 63 | 64 | return finalArr; 65 | }; -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/4.Counter-II/CounterII.ts: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Write a function createCounter. It should accept an initial integer init. It should return an object with three functions. 4 | 5 | The three functions are: 6 | 7 | increment() increases the current value by 1 and then returns it. 8 | decrement() reduces the current value by 1 and then returns it. 9 | reset() sets the current value to init and then returns it. 10 | 11 | 12 | Example 1: 13 | 14 | Input: init = 5, calls = ["increment","reset","decrement"] 15 | Output: [6,5,4] 16 | Explanation: 17 | const counter = createCounter(5); 18 | counter.increment(); // 6 19 | counter.reset(); // 5 20 | counter.decrement(); // 4 21 | Example 2: 22 | 23 | Input: init = 0, calls = ["increment","increment","decrement","reset","reset"] 24 | Output: [1,2,1,0,0] 25 | Explanation: 26 | const counter = createCounter(0); 27 | counter.increment(); // 1 28 | counter.increment(); // 2 29 | counter.decrement(); // 1 30 | counter.reset(); // 0 31 | counter.reset(); // 0 32 | 33 | 34 | Constraints: 35 | 36 | -1000 <= init <= 1000 37 | 0 <= calls.length <= 1000 38 | calls[i] is one of "increment", "decrement" and "reset" 39 | 40 | */ 41 | 42 | 43 | type Counter = { 44 | increment: () => number, 45 | decrement: () => number, 46 | reset: () => number, 47 | } 48 | 49 | function createCounter(init: number): Counter { 50 | let val = init; 51 | return { 52 | increment() { 53 | return ++val; 54 | }, 55 | decrement() { 56 | return --val; 57 | }, 58 | reset() { 59 | val = init; 60 | return val; 61 | }, 62 | }; 63 | }; 64 | 65 | const counter = createCounter(5) 66 | console.log(counter.increment()); // 6 67 | console.log(counter.reset());// 5 68 | console.log(counter.decrement()); // 4 69 | -------------------------------------------------------------------------------- /challanges1-to-72/problem54/problem54.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | 4 | Create a function called highestRunScorer that will 5 | Receive a 2d array called playersInfo 6 | Based on highest score, return the name of the player 7 | 8 | Things required 9 | Variable 10 | If-else 11 | Loop 12 | Function 13 | Array 14 | 15 | */ 16 | 17 | 18 | /* ========================================= 19 | Method One: (Complex) 20 | ============================================= */ 21 | 22 | /* const highestRunScorer = players => { 23 | const allPlayersRun = []; 24 | for( let i = 0; i < players.length; i++){ 25 | 26 | const player = players[i]; 27 | const playerRun = player[1]; 28 | allPlayersRun.push(playerRun); 29 | } 30 | 31 | const topRuns = Math.max(...allPlayersRun); 32 | 33 | for( let x = 0; x < players.length; x++){ 34 | if(players[x][1] == topRuns){ 35 | 36 | return players[x][0]; 37 | } 38 | } 39 | } 40 | */ 41 | 42 | /* ========================================= 43 | Method Two: (Simple) 44 | ============================================= */ 45 | 46 | function highestRunScorer(players){ 47 | let highestScorer = players [0][0]; 48 | let highestRun = players[0][1]; 49 | 50 | for(var i = 1; i < players.length; i++){ 51 | 52 | if(highestRun < players[i][1]){ 53 | 54 | highestRun = players[i][1] 55 | highestScorer = players[i][0]; 56 | } 57 | } 58 | return highestScorer; 59 | } 60 | 61 | const playersInfo = [ 62 | ["Sakib", 19], 63 | ["Musfique", 35], 64 | ["Asraful", 95], 65 | ["Mahmudullah", 45], 66 | ["Mashrafee", 13], 67 | ["Shourav", 115] 68 | ]; 69 | 70 | const result = highestRunScorer(playersInfo); 71 | 72 | console.log(`The highest run scorer is ${result}`); 73 | 74 | -------------------------------------------------------------------------------- /challanges1-to-72/problem36/problem36.js: -------------------------------------------------------------------------------- 1 | /* কেউ ১০০ এর মধ্যে কত মার্ক্স্ পেয়েছে সেটা তোমাকে বলে দিবে। তুমি একটা ফাংশন দিয়ে বলে দিবে সে এ+ পাবে নাকি অন্য কোন গ্রেড পাবে। */ 2 | 3 | 4 | 5 | 6 | function gpa(num){ 7 | 8 | if( num >= 0 && num <= 100){ 9 | 10 | if((num >= 0) && ( num < 33)){ 11 | const massage = "Your number is " + num + " so your GPA is 'F' means you failed in the exam "; 12 | return massage; 13 | } 14 | 15 | else if((num >= 33) && ( num < 40)){ 16 | const massage = "Your number is " + num + " so your GPA is 'D' "; 17 | return massage; 18 | } 19 | 20 | else if((num >= 40) && ( num < 50)){ 21 | const massage = "Your number is " + num + " so your GPA is 'C' "; 22 | return massage; 23 | } 24 | 25 | else if ((num >= 50) && (num < 60)){ 26 | const massage = "Your number is " + num + " so your GPA is 'B' "; 27 | return massage; 28 | } 29 | else if ( (num >= 60) && (num < 70)){ 30 | const massage = "Your number is " + num + " so your GPA is 'A-' "; 31 | return massage; 32 | } 33 | 34 | else if ((num >= 70) && (num < 80)){ 35 | const massage = "Your number is " + num + " so your GPA is 'A' "; 36 | return massage; 37 | } 38 | else{ 39 | const massage = "Congratulations💐💐 !! Your number is " + num + " so your GPA is 'A+' "; 40 | return massage; 41 | } 42 | } 43 | 44 | else{ 45 | const warningMassage = "⚠️⚠️You input an invalid number. Please input number between 0 to 100."; 46 | return warningMassage; 47 | } 48 | }; 49 | 50 | 51 | 52 | const result = 79; 53 | const resultInGrade = gpa(result); 54 | console.log(resultInGrade); -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/10.Allow_One_Function_Call/Allow_One_Function_Call.ts: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Given a function fn, return a new function that is identical to the original function except that it ensures fn is called at most once. 4 | 5 | The first time the returned function is called, it should return the same result as fn. 6 | Every subsequent time it is called, it should return undefined. 7 | 8 | 9 | Example 1: 10 | 11 | Input: fn = (a,b,c) => (a + b + c), calls = [[1,2,3],[2,3,6]] 12 | Output: [{"calls":1,"value":6}] 13 | Explanation: 14 | const onceFn = once(fn); 15 | onceFn(1, 2, 3); // 6 16 | onceFn(2, 3, 6); // undefined, fn was not called 17 | Example 2: 18 | 19 | Input: fn = (a,b,c) => (a * b * c), calls = [[5,7,4],[2,3,6],[4,6,8]] 20 | Output: [{"calls":1,"value":140}] 21 | Explanation: 22 | const onceFn = once(fn); 23 | onceFn(5, 7, 4); // 140 24 | onceFn(2, 3, 6); // undefined, fn was not called 25 | onceFn(4, 6, 8); // undefined, fn was not called 26 | 27 | 28 | Constraints: 29 | 30 | calls is a valid JSON array 31 | 1 <= calls.length <= 10 32 | 1 <= calls[i].length <= 100 33 | 2 <= JSON.stringify(calls).length <= 1000 34 | 35 | 36 | 37 | 38 | 39 | 40 | */ 41 | 42 | 43 | 44 | type JSONValue = null | boolean | number | string | JSONValue[] | { [key: string]: JSONValue }; 45 | type OnceFn = (...args: JSONValue[]) => JSONValue | undefined; 46 | 47 | function once(fn: Function): OnceFn { 48 | let called = false; 49 | let rst: JSONValue; 50 | 51 | return function (...args: JSONValue[]): JSONValue | undefined { 52 | if (!called) { 53 | called = true; 54 | rst = fn(...args); 55 | return rst; 56 | } 57 | return undefined; 58 | }; 59 | } 60 | /** 61 | * let fn = (a,b,c) => (a + b + c) 62 | * let onceFn = once(fn) 63 | * 64 | * onceFn(1,2,3); // 6 65 | * onceFn(2,3,6); // returns undefined without calling fn 66 | */ -------------------------------------------------------------------------------- /challanges1-to-72/problem11/problem11.js: -------------------------------------------------------------------------------- 1 | /* প্রাকটিস চ্যালেঞ্জ-১ 2 | 3 | প্রতিদিন তোমার কাজ কি? 4 | 5 | ১) রাত ৮ টা বাজে মডিউল আনলক করো 6 | 7 | ২) ফটাফট ভিডিও দেখে দেখে প্রাকটিস করো 8 | 9 | ৩) ভিডিও দেখতে দেখতে নোটস নাও 10 | 11 | ৪) মডিউল শেষ হলে পুরা মডিউল নিজে নিজে প্রাকটিস করো 12 | 13 | ৫) কোন কিছু বুঝতে না পারলে (চিন্তা করে দেখো এইখানে কিন্তু একটা শর্ত আছে ), সাপোর্ট সেশনে জয়েন করো 14 | 15 | এখন তোমার কাজ হচ্ছে একটা for লুপ 5 বার চালিয়ে উপরের জিনিসগুলা আউটপুট হিসেবে দেখানো। */ 16 | 17 | 18 | /* var myDayTask = ["1. Unlock videos 8pm","2. Watch these videos", "3. Taking Notes", "4. Practice the module", "5. If confused take help"]; 19 | 20 | for( var i = 0; i < myDayTask.length; i++){ 21 | 22 | var myTask=myDayTask[i]; 23 | console.log(myTask); 24 | } 25 | */ 26 | 27 | /* প্রাকটিস চ্যালেঞ্জ-২: 28 | 29 | আবার একই জিনিস while লুপ চালিয়ে দেখানো। */ 30 | 31 | 32 | /* var myDayTask = ["1. Unlock videos 8pm","2. Watch these videos", "3. Taking Notes", "4. Practice the module", "5. If confused take help"]; 33 | 34 | var i = 0 ; 35 | 36 | while( i < myDayTask.length){ 37 | var myTask = myDayTask[i]; 38 | console.log(myTask); 39 | 40 | i++; 41 | } */ 42 | 43 | 44 | 45 | 46 | // প্রাকটিস চ্যালেঞ্জ-৩: 47 | 48 | // উপরের প্রব্লেমটাই while লুপ রিভার্স ওয়েতে (decremental হিসেবে)করে দেখাও 49 | 50 | /* 51 | var myDayTask = ["1. Unlock videos 8pm","2. Watch these videos", "3. Taking Notes", "4. Practice the module", "5. If confused take help"]; 52 | 53 | var i = myDayTask.length - 1; 54 | 55 | while( i >= 0){ 56 | var myTask = myDayTask[i]; 57 | console.log(myTask); 58 | i--; 59 | } */ 60 | 61 | 62 | 63 | //প্রাকটিস চ্যালেঞ্জ-৪: 64 | 65 | //উপরের প্রব্লেমটাই for লুপ রিভার্স ওয়েতে (decremental হিসেবে)করে দেখাও 66 | 67 | var myDayTask = ["1. Unlock videos 8pm","2. Watch these videos", "3. Taking Notes", "4. Practice the module", "5. If confused take help"]; 68 | 69 | 70 | for( var i = myDayTask.length - 1; i >= 0; i--){ 71 | var myTask = myDayTask[i]; 72 | 73 | console.log(myTask); 74 | } -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/7.Array_Reduce_Transformation/Array_Reduce_Transformation.ts: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | 4 | Given an integer array nums, a reducer function fn, and an initial value init, return the final result obtained by executing the fn function on each element of the array, sequentially, passing in the return value from the calculation on the preceding element. 5 | 6 | This result is achieved through the following operations: val = fn(init, nums[0]), val = fn(val, nums[1]), val = fn(val, nums[2]), ... until every element in the array has been processed. The ultimate value of val is then returned. 7 | 8 | If the length of the array is 0, the function should return init. 9 | 10 | Please solve it without using the built-in Array.reduce method. 11 | 12 | 13 | 14 | Example 1: 15 | 16 | Input: 17 | nums = [1,2,3,4] 18 | fn = function sum(accum, curr) { return accum + curr; } 19 | init = 0 20 | Output: 10 21 | Explanation: 22 | initially, the value is init=0. 23 | (0) + nums[0] = 1 24 | (1) + nums[1] = 3 25 | (3) + nums[2] = 6 26 | (6) + nums[3] = 10 27 | The final answer is 10. 28 | Example 2: 29 | 30 | Input: 31 | nums = [1,2,3,4] 32 | fn = function sum(accum, curr) { return accum + curr * curr; } 33 | init = 100 34 | Output: 130 35 | Explanation: 36 | initially, the value is init=100. 37 | (100) + nums[0] * nums[0] = 101 38 | (101) + nums[1] * nums[1] = 105 39 | (105) + nums[2] * nums[2] = 114 40 | (114) + nums[3] * nums[3] = 130 41 | The final answer is 130. 42 | Example 3: 43 | 44 | Input: 45 | nums = [] 46 | fn = function sum(accum, curr) { return 0; } 47 | init = 25 48 | Output: 25 49 | Explanation: For empty arrays, the answer is always init. 50 | 51 | 52 | Constraints: 53 | 54 | 0 <= nums.length <= 1000 55 | 0 <= nums[i] <= 1000 56 | 0 <= init <= 1000 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | */ 69 | 70 | 71 | 72 | type Fn = (accum: number, curr: number) => number 73 | 74 | function reduce(nums: number[], fn: Fn, init: number): number { 75 | let fnlVal = init; 76 | for(let i = 0; i < nums.length; i++){ 77 | fnlVal = fn(fnlVal, nums[i]); 78 | 79 | } 80 | 81 | return fnlVal; 82 | }; -------------------------------------------------------------------------------- /challanges1-to-72/problem48/problem48.js: -------------------------------------------------------------------------------- 1 | /* 2 | ## Practice Problem 47 ( map(), filter(), find() ) 3 | 4 | 1. You have an odd array (array with odd numbers). [ 1, 3, 5, 7, 9 ]. 5 | Now convert this array into an even array (array with even 6 | numbers). [ 2, 4, 6, 8, 10 ]. Do this using for loop & array.map() 7 | method. Hints: add one to any odd number and it will become an even 8 | number. 9 | 10 | 2. You are given an array say: [33, 50, 79, 78, 90, 101, 30 ]. Now 11 | return/get all the elements which are divisible by 10 using 12 | array.filter() method. 13 | 14 | 3. Now do the same task of question 2. But do this using array.find() 15 | method. Then compare the output of question 2 & question 3. 16 | 17 | 18 | 19 | prblem provider source : https://drive.google.com/file/d/1XcvIBe_rJlr6GY2rTnHlbIluTABXNhp7/view 20 | 21 | */ 22 | 23 | 24 | /* =========================== 25 | Task One: 26 | ============================== */ 27 | 28 | const oddNumbers = [ 1, 3, 5, 7, 9 ] ; 29 | const evenNumbersUsingLoop = []; 30 | 31 | /* Using for loop */ 32 | 33 | for( var i = 0; i < oddNumbers.length; i++){ 34 | const number = oddNumbers[i]; 35 | const evenNumber = number + 1 ; 36 | evenNumbersUsingLoop.push(evenNumber) 37 | }; 38 | 39 | console.log(evenNumbersUsingLoop); 40 | 41 | /* Using map() */ 42 | 43 | const evenNumbers = oddNumbers.map( number => number + 1); 44 | console.log(evenNumbers); 45 | 46 | /* =========================== 47 | Task Two: 48 | ============================== */ 49 | 50 | const randomNumbers = [33, 50, 79, 78, 90, 101, 30 ] ; 51 | 52 | const numbersDividedBy10 = randomNumbers.filter( number => number % 10 === 0); 53 | console.log(numbersDividedBy10); 54 | 55 | 56 | 57 | /* =========================== 58 | Task Three: 59 | ============================== */ 60 | 61 | const firstNumberDividedBy10 = randomNumbers.find( number => number % 10 === 0); 62 | console.log(firstNumberDividedBy10); 63 | 64 | const compareTask2AndTask3 = ` 65 | The result of Task 2 is ${numbersDividedBy10}. (using filter method) 66 | And 67 | The result of Task 3 is ${firstNumberDividedBy10}. (using find method) 68 | `; 69 | 70 | console.log(compareTask2AndTask3); 71 | -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/17.Cache_with_Time_Limit/Cache_with_Time_Limit.ts: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Write a class that allows getting and setting key-value pairs, however a time until expiration is associated with each key. 4 | 5 | The class has three public methods: 6 | 7 | set(key, value, duration): accepts an integer key, an integer value, and a duration in milliseconds. Once the duration has elapsed, the key should be inaccessible. The method should return true if the same un-expired key already exists and false otherwise. Both the value and duration should be overwritten if the key already exists. 8 | 9 | get(key): if an un-expired key exists, it should return the associated value. Otherwise it should return -1. 10 | 11 | count(): returns the count of un-expired keys. 12 | 13 | 14 | 15 | Example 1: 16 | 17 | Input: 18 | actions = ["TimeLimitedCache", "set", "get", "count", "get"] 19 | values = [[], [1, 42, 100], [1], [], [1]] 20 | timeDelays = [0, 0, 50, 50, 150] 21 | Output: [null, false, 42, 1, -1] 22 | Explanation: 23 | At t=0, the cache is constructed. 24 | At t=0, a key-value pair (1: 42) is added with a time limit of 100ms. The value doesn't exist so false is returned. 25 | At t=50, key=1 is requested and the value of 42 is returned. 26 | At t=50, count() is called and there is one active key in the cache. 27 | At t=100, key=1 expires. 28 | At t=150, get(1) is called but -1 is returned because the cache is empty. 29 | Example 2: 30 | 31 | Input: 32 | actions = ["TimeLimitedCache", "set", "set", "get", "get", "get", "count"] 33 | values = [[], [1, 42, 50], [1, 50, 100], [1], [1], [1], []] 34 | timeDelays = [0, 0, 40, 50, 120, 200, 250] 35 | Output: [null, false, true, 50, 50, -1, 0] 36 | Explanation: 37 | At t=0, the cache is constructed. 38 | At t=0, a key-value pair (1: 42) is added with a time limit of 50ms. The value doesn't exist so false is returned. 39 | At t=40, a key-value pair (1: 50) is added with a time limit of 100ms. A non-expired value already existed so true is returned and the old value was overwritten. 40 | At t=50, get(1) is called which returned 50. 41 | At t=120, get(1) is called which returned 50. 42 | At t=140, key=1 expires. 43 | At t=200, get(1) is called but the cache is empty so -1 is returned. 44 | At t=250, count() returns 0 because the cache is empty. 45 | 46 | 47 | Constraints: 48 | 49 | 0 <= key, value <= 109 50 | 0 <= duration <= 1000 51 | 1 <= actions.length <= 100 52 | actions.length === values.length 53 | actions.length === timeDelays.length 54 | 0 <= timeDelays[i] <= 1450 55 | actions[i] is one of "TimeLimitedCache", "set", "get" and "count" 56 | First action is always "TimeLimitedCache" and must be executed immediately, with a 0-millisecond delay 57 | 58 | 59 | 60 | 61 | 62 | 63 | */ 64 | 65 | 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 4 |

Hello there, I am Shourav Raj 6 | 7 | 10 | ##

[![Typing SVG](https://readme-typing-svg.demolab.com?font=arial+black&size=24&pause=1000&color=D41953¢er=true&width=410&lines=%F0%9F%8C%90+Web+Developer;%F0%9F%91%A8%E2%80%8D%F0%9F%92%BB+Full+Stack+Developer;%F0%9F%92%BB+MERN+Stack+Developer;%E2%9A%99+React+Developer;%F0%9F%91%A8%E2%80%8D%F0%9F%92%BB+Frontend+Developer;%F0%9F%8E%93+JavaScript+Developer;%F0%9F%90%B1%E2%80%8D%F0%9F%8F%8D+Node+js+Developer;%F0%9F%93%B1+React+Native+developer)](https://developer-shourav.web.app)

11 | 12 | 13 |

Here is a list of JavaScript problems that I solved.
I keep here the problem with solutions and the problem getting source also.
Check "problem.md" file to get details about the problem and the provider.
Thank you💖

14 | 15 | 16 | 19 | 20 | ### **`Reach me`**: 21 | 22 |

23 | https://developer-shourav.web.app 24 | Linkedin-icon 25 | mailto:developer.shourav1@gmail.com 26 | https://wa.me/+8801932376388 27 | https://join.skype.com/invite/pem7MobNeCzH 28 | https://telegram.me/Developer_Shourav 29 | https://m.me/developer.shourav 30 | Facebook-icon 31 |

32 | 33 | 34 | -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/14.Timeout_Cancellation/Timeout_Cancellation.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Given a function fn, an array of arguments args, and a timeout t in milliseconds, return a cancel function cancelFn. 3 | 4 | After a delay of cancelTimeMs, the returned cancel function cancelFn will be invoked. 5 | 6 | setTimeout(cancelFn, cancelTimeMs) 7 | Initially, the execution of the function fn should be delayed by t milliseconds. 8 | 9 | If, before the delay of t milliseconds, the function cancelFn is invoked, it should cancel the delayed execution of fn. Otherwise, if cancelFn is not invoked within the specified delay t, fn should be executed with the provided args as arguments. 10 | 11 | 12 | 13 | Example 1: 14 | 15 | Input: fn = (x) => x * 5, args = [2], t = 20 16 | Output: [{"time": 20, "returned": 10}] 17 | Explanation: 18 | const cancelTimeMs = 50; 19 | const cancelFn = cancellable((x) => x * 5, [2], 20); 20 | setTimeout(cancelFn, cancelTimeMs); 21 | 22 | The cancellation was scheduled to occur after a delay of cancelTimeMs (50ms), which happened after the execution of fn(2) at 20ms. 23 | Example 2: 24 | 25 | Input: fn = (x) => x**2, args = [2], t = 100 26 | Output: [] 27 | Explanation: 28 | const cancelTimeMs = 50; 29 | const cancelFn = cancellable((x) => x**2, [2], 100); 30 | setTimeout(cancelFn, cancelTimeMs); 31 | 32 | The cancellation was scheduled to occur after a delay of cancelTimeMs (50ms), which happened before the execution of fn(2) at 100ms, resulting in fn(2) never being called. 33 | Example 3: 34 | 35 | Input: fn = (x1, x2) => x1 * x2, args = [2,4], t = 30 36 | Output: [{"time": 30, "returned": 8}] 37 | Explanation: 38 | const cancelTimeMs = 100; 39 | const cancelFn = cancellable((x1, x2) => x1 * x2, [2,4], 30); 40 | setTimeout(cancelFn, cancelTimeMs); 41 | 42 | The cancellation was scheduled to occur after a delay of cancelTimeMs (100ms), which happened after the execution of fn(2,4) at 30ms. 43 | 44 | 45 | Constraints: 46 | 47 | fn is a function 48 | args is a valid JSON array 49 | 1 <= args.length <= 10 50 | 20 <= t <= 1000 51 | 10 <= cancelTimeMs <= 1000 52 | 53 | 54 | 55 | */ 56 | 57 | 58 | 59 | 60 | type JSONValue = null | boolean | number | string | JSONValue[] | { [key: string]: JSONValue }; 61 | type Fn = (...args: JSONValue[]) => void; 62 | 63 | function cancellable(fn: Fn, args: JSONValue[], t: number): Function { 64 | const tmr = setTimeout(() => { 65 | fn(...args); 66 | }, t); 67 | 68 | return function cnlFn() { 69 | clearTimeout(tmr); 70 | }; 71 | } 72 | 73 | /** 74 | * const result = []; 75 | * 76 | * const fn = (x) => x * 5; 77 | * const args = [2], t = 20, cancelTimeMs = 50; 78 | * 79 | * const start = performance.now(); 80 | * 81 | * const log = (...argsArr) => { 82 | * const diff = Math.floor(performance.now() - start); 83 | * result.push({"time": diff, "returned": fn(...argsArr)}); 84 | * } 85 | * 86 | * const cancel = cancellable(log, args, t); 87 | * 88 | * const maxT = Math.max(t, cancelTimeMs); 89 | * 90 | * setTimeout(cancel, cancelTimeMs); 91 | * 92 | * setTimeout(() => { 93 | * console.log(result); // [{"time":20,"returned":10}] 94 | * }, maxT + 15) 95 | */ -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/16.Promise_Time_Limite/Promise_Time_Limite.ts: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Given an asynchronous function fn and a time t in milliseconds, return a new time limited version of the input function. fn takes arguments provided to the time limited function. 4 | 5 | The time limited function should follow these rules: 6 | 7 | If the fn completes within the time limit of t milliseconds, the time limited function should resolve with the result. 8 | If the execution of the fn exceeds the time limit, the time limited function should reject with the string "Time Limit Exceeded". 9 | 10 | 11 | Example 1: 12 | 13 | Input: 14 | fn = async (n) => { 15 | await new Promise(res => setTimeout(res, 100)); 16 | return n * n; 17 | } 18 | inputs = [5] 19 | t = 50 20 | Output: {"rejected":"Time Limit Exceeded","time":50} 21 | Explanation: 22 | const limited = timeLimit(fn, t) 23 | const start = performance.now() 24 | let result; 25 | try { 26 | const res = await limited(...inputs) 27 | result = {"resolved": res, "time": Math.floor(performance.now() - start)}; 28 | } catch (err) { 29 | result = {"rejected": err, "time": Math.floor(performance.now() - start)}; 30 | } 31 | console.log(result) // Output 32 | 33 | The provided function is set to resolve after 100ms. However, the time limit is set to 50ms. It rejects at t=50ms because the time limit was reached. 34 | Example 2: 35 | 36 | Input: 37 | fn = async (n) => { 38 | await new Promise(res => setTimeout(res, 100)); 39 | return n * n; 40 | } 41 | inputs = [5] 42 | t = 150 43 | Output: {"resolved":25,"time":100} 44 | Explanation: 45 | The function resolved 5 * 5 = 25 at t=100ms. The time limit is never reached. 46 | Example 3: 47 | 48 | Input: 49 | fn = async (a, b) => { 50 | await new Promise(res => setTimeout(res, 120)); 51 | return a + b; 52 | } 53 | inputs = [5,10] 54 | t = 150 55 | Output: {"resolved":15,"time":120} 56 | Explanation: 57 | ​​​​The function resolved 5 + 10 = 15 at t=120ms. The time limit is never reached. 58 | Example 4: 59 | 60 | Input: 61 | fn = async () => { 62 | throw "Error"; 63 | } 64 | inputs = [] 65 | t = 1000 66 | Output: {"rejected":"Error","time":0} 67 | Explanation: 68 | The function immediately throws an error. 69 | 70 | 71 | Constraints: 72 | 73 | 0 <= inputs.length <= 10 74 | 0 <= t <= 1000 75 | fn returns a promise 76 | 77 | 78 | 79 | 80 | */ 81 | 82 | 83 | type Fn = (...params: any[]) => Promise; 84 | 85 | function timeLimit(fn: Fn, t: number): Fn { 86 | 87 | return async function (...args: any[]) { 88 | return new Promise((delayresolve, rej) => { 89 | const tOutId = setTimeout(() => { 90 | clearTimeout(tOutId); 91 | rej("Time Limit Exceeded"); 92 | }, t); 93 | 94 | fn(...args) 95 | .then((res) => { 96 | clearTimeout(tOutId); 97 | delayresolve(res); 98 | }) 99 | .catch((e) => { 100 | clearTimeout(tOutId); 101 | rej(e); 102 | }); 103 | }); 104 | }; 105 | }; 106 | 107 | /** 108 | * const limited = timeLimit((t) => new Promise(res => setTimeout(res, t)), 100); 109 | * limited(150).catch(console.log) // "Time Limit Exceeded" at t=100ms 110 | */ -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/11.Memoize/Memoize.ts: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | 4 | Given a function fn, return a memoized version of that function. 5 | 6 | A memoized function is a function that will never be called twice with the same inputs. Instead it will return a cached value. 7 | 8 | You can assume there are 3 possible input functions: sum, fib, and factorial. 9 | 10 | sum accepts two integers a and b and returns a + b. Assume that if a value has already been cached for the arguments (b, a) where a != b, it cannot be used for the arguments (a, b). For example, if the arguments are (3, 2) and (2, 3), two separate calls should be made. 11 | fib accepts a single integer n and returns 1 if n <= 1 or fib(n - 1) + fib(n - 2) otherwise. 12 | factorial accepts a single integer n and returns 1 if n <= 1 or factorial(n - 1) * n otherwise. 13 | 14 | 15 | Example 1: 16 | 17 | Input: 18 | fnName = "sum" 19 | actions = ["call","call","getCallCount","call","getCallCount"] 20 | values = [[2,2],[2,2],[],[1,2],[]] 21 | Output: [4,4,1,3,2] 22 | Explanation: 23 | const sum = (a, b) => a + b; 24 | const memoizedSum = memoize(sum); 25 | memoizedSum(2, 2); // "call" - returns 4. sum() was called as (2, 2) was not seen before. 26 | memoizedSum(2, 2); // "call" - returns 4. However sum() was not called because the same inputs were seen before. 27 | // "getCallCount" - total call count: 1 28 | memoizedSum(1, 2); // "call" - returns 3. sum() was called as (1, 2) was not seen before. 29 | // "getCallCount" - total call count: 2 30 | Example 2: 31 | 32 | Input: 33 | fnName = "factorial" 34 | actions = ["call","call","call","getCallCount","call","getCallCount"] 35 | values = [[2],[3],[2],[],[3],[]] 36 | Output: [2,6,2,2,6,2] 37 | Explanation: 38 | const factorial = (n) => (n <= 1) ? 1 : (n * factorial(n - 1)); 39 | const memoFactorial = memoize(factorial); 40 | memoFactorial(2); // "call" - returns 2. 41 | memoFactorial(3); // "call" - returns 6. 42 | memoFactorial(2); // "call" - returns 2. However factorial was not called because 2 was seen before. 43 | // "getCallCount" - total call count: 2 44 | memoFactorial(3); // "call" - returns 6. However factorial was not called because 3 was seen before. 45 | // "getCallCount" - total call count: 2 46 | Example 3: 47 | 48 | Input: 49 | fnName = "fib" 50 | actions = ["call","getCallCount"] 51 | values = [[5],[]] 52 | Output: [8,1] 53 | Explanation: 54 | fib(5) = 8 // "call" 55 | // "getCallCount" - total call count: 1 56 | 57 | 58 | Constraints: 59 | 60 | 0 <= a, b <= 105 61 | 1 <= n <= 10 62 | 1 <= actions.length <= 105 63 | actions.length === values.length 64 | actions[i] is one of "call" and "getCallCount" 65 | fnName is one of "sum", "factorial" and "fib" 66 | 67 | 68 | 69 | 70 | */ 71 | 72 | 73 | 74 | 75 | type Fn = (...params: number[]) => number; 76 | 77 | function memoize(fn: Fn): Fn { 78 | const cache: { [key: string]: number } = {}; 79 | 80 | return function (...args: number[]): number { 81 | const key = args.join(','); 82 | if (key in cache) { 83 | return cache[key]; 84 | } 85 | const result = fn(...args); 86 | cache[key] = result; 87 | return result; 88 | } 89 | } 90 | 91 | 92 | /** 93 | * let callCount = 0; 94 | * const memoizedFn = memoize(function (a, b) { 95 | * callCount += 1; 96 | * return a + b; 97 | * }) 98 | * memoizedFn(2, 3) // 5 99 | * memoizedFn(2, 3) // 5 100 | * console.log(callCount) // 1 101 | */ -------------------------------------------------------------------------------- /LeetCode/30daysJavaScript/15.Interval_Cancellation/Interval_Cancellation.ts: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Interval Cancellation 4 | Easy 5 | premium lock icon 6 | Companies 7 | Given a function fn, an array of arguments args, and an interval time t, return a cancel function cancelFn. 8 | 9 | After a delay of cancelTimeMs, the returned cancel function cancelFn will be invoked. 10 | 11 | setTimeout(cancelFn, cancelTimeMs) 12 | The function fn should be called with args immediately and then called again every t milliseconds until cancelFn is called at cancelTimeMs ms. 13 | 14 | 15 | 16 | Example 1: 17 | 18 | Input: fn = (x) => x * 2, args = [4], t = 35 19 | Output: 20 | [ 21 | {"time": 0, "returned": 8}, 22 | {"time": 35, "returned": 8}, 23 | {"time": 70, "returned": 8}, 24 | {"time": 105, "returned": 8}, 25 | {"time": 140, "returned": 8}, 26 | {"time": 175, "returned": 8} 27 | ] 28 | Explanation: 29 | const cancelTimeMs = 190; 30 | const cancelFn = cancellable((x) => x * 2, [4], 35); 31 | setTimeout(cancelFn, cancelTimeMs); 32 | 33 | Every 35ms, fn(4) is called. Until t=190ms, then it is cancelled. 34 | 1st fn call is at 0ms. fn(4) returns 8. 35 | 2nd fn call is at 35ms. fn(4) returns 8. 36 | 3rd fn call is at 70ms. fn(4) returns 8. 37 | 4th fn call is at 105ms. fn(4) returns 8. 38 | 5th fn call is at 140ms. fn(4) returns 8. 39 | 6th fn call is at 175ms. fn(4) returns 8. 40 | Cancelled at 190ms 41 | Example 2: 42 | 43 | Input: fn = (x1, x2) => (x1 * x2), args = [2, 5], t = 30 44 | Output: 45 | [ 46 | {"time": 0, "returned": 10}, 47 | {"time": 30, "returned": 10}, 48 | {"time": 60, "returned": 10}, 49 | {"time": 90, "returned": 10}, 50 | {"time": 120, "returned": 10}, 51 | {"time": 150, "returned": 10} 52 | ] 53 | Explanation: 54 | const cancelTimeMs = 165; 55 | const cancelFn = cancellable((x1, x2) => (x1 * x2), [2, 5], 30) 56 | setTimeout(cancelFn, cancelTimeMs) 57 | 58 | Every 30ms, fn(2, 5) is called. Until t=165ms, then it is cancelled. 59 | 1st fn call is at 0ms 60 | 2nd fn call is at 30ms 61 | 3rd fn call is at 60ms 62 | 4th fn call is at 90ms 63 | 5th fn call is at 120ms 64 | 6th fn call is at 150ms 65 | Cancelled at 165ms 66 | Example 3: 67 | 68 | Input: fn = (x1, x2, x3) => (x1 + x2 + x3), args = [5, 1, 3], t = 50 69 | Output: 70 | [ 71 | {"time": 0, "returned": 9}, 72 | {"time": 50, "returned": 9}, 73 | {"time": 100, "returned": 9}, 74 | {"time": 150, "returned": 9} 75 | ] 76 | Explanation: 77 | const cancelTimeMs = 180; 78 | const cancelFn = cancellable((x1, x2, x3) => (x1 + x2 + x3), [5, 1, 3], 50) 79 | setTimeout(cancelFn, cancelTimeMs) 80 | 81 | Every 50ms, fn(5, 1, 3) is called. Until t=180ms, then it is cancelled. 82 | 1st fn call is at 0ms 83 | 2nd fn call is at 50ms 84 | 3rd fn call is at 100ms 85 | 4th fn call is at 150ms 86 | Cancelled at 180ms 87 | 88 | 89 | Constraints: 90 | 91 | fn is a function 92 | args is a valid JSON array 93 | 1 <= args.length <= 10 94 | 30 <= t <= 100 95 | 10 <= cancelTimeMs <= 500 96 | 97 | 98 | */ 99 | 100 | 101 | type JSONValue = null | boolean | number | string | JSONValue[] | { [key: string]: JSONValue }; 102 | type Fn = (...args: JSONValue[]) => void; 103 | 104 | function cancellable(fn: Fn, args: JSONValue[], t: number): () => void { 105 | 106 | fn(...args); 107 | 108 | const invId = setInterval(() => { 109 | fn(...args); 110 | }, t); 111 | 112 | return () => clearInterval(invId); 113 | } 114 | /** 115 | * const result = []; 116 | * 117 | * const fn = (x) => x * 2; 118 | * const args = [4], t = 35, cancelTimeMs = 190; 119 | * 120 | * const start = performance.now(); 121 | * 122 | * const log = (...argsArr) => { 123 | * const diff = Math.floor(performance.now() - start); 124 | * result.push({"time": diff, "returned": fn(...argsArr)}); 125 | * } 126 | * 127 | * const cancel = cancellable(log, args, t); 128 | * 129 | * setTimeout(cancel, cancelTimeMs); 130 | * 131 | * setTimeout(() => { 132 | * console.log(result); // [ 133 | * // {"time":0,"returned":8}, 134 | * // {"time":35,"returned":8}, 135 | * // {"time":70,"returned":8}, 136 | * // {"time":105,"returned":8}, 137 | * // {"time":140,"returned":8}, 138 | * // {"time":175,"returned":8} 139 | * // ] 140 | * }, cancelTimeMs + t + 15) 141 | */ -------------------------------------------------------------------------------- /challanges1-to-72/problem8/problem8.js: -------------------------------------------------------------------------------- 1 | /* You and your friends Tom, Jane, Peter and John got their final exam results. Your total 2 | score is 85, Tom’s total score is 66, Jane’s total score is 95, Peter’s total score is 56 3 | and John’s total score is 40. The grading chart is 4 | 80 or above A grade 5 | 60 or above B grade 6 | 50 or above C grade 7 | 40 or above D grade 8 | 39 or less => F grade 9 | 10 | Write a program to find your and your friends’ grades using if-else. 11 | 12 | 13 | 14 | [View problem source 📤](https://drive.google.com/file/d/1bfxye7A1p-BBJCQCXaiUetl_qyS2Vc1E/view) */ 15 | 16 | 17 | var myResult = 85; 18 | var tomsResult = 66; 19 | var janesResult = 95; 20 | var petersResult = 56; 21 | var johnsResult = 40; 22 | 23 | 24 | /* --------------------------------------------------------------------------- 25 | Program for finding my and my friends’ grades using if-else. 26 | -------------------------------------------------------------------------- */ 27 | 28 | 29 | /* ----------------------------- 30 | For my result 31 | --------------------------------- */ 32 | 33 | if( myResult <= 39){ 34 | console.log("Sorry !! Shourav😞😥 you failed in the exam. You got " + myResult + " out of 100. So your Grad is 'F' ") ; 35 | } 36 | 37 | else if( 40 <= myResult && myResult < 50 ){ 38 | console.log("Congratulations Shourav🥳💐💐 !! you passed the exam. You got " + myResult + " out of 100. So your Grad is 'D' ") ; 39 | } 40 | 41 | else if( 50 <= myResult && myResult < 60 ){ 42 | console.log("Congratulations Shourav🥳💐💐 !! you passed the exam. You got " + myResult + " out of 100. So your Grad is 'C' ") ; 43 | } 44 | 45 | else if( 60 <= myResult && myResult < 80 ){ 46 | console.log("Congratulations Shourav🥳💐💐 !! you passed the exam. You got " + myResult + " out of 100. So your Grad is 'B' ") ; 47 | } 48 | 49 | else { 50 | console.log("Congratulations Shourav, It's Awesome🥳💖💕 !! you are the Best. You got " + myResult + " out of 100. So your Grad is 'A' ") ; 51 | } 52 | 53 | 54 | /* ----------------------------- 55 | For Tom's Result 56 | --------------------------------- */ 57 | 58 | if( tomsResult <= 39){ 59 | console.log("Sorry !! Tom😞😥 you failed in the exam. You got " + tomsResult + " out of 100. So your Grad is 'F' ") ; 60 | } 61 | 62 | else if( 40 <= tomsResult && tomsResult < 50 ){ 63 | console.log("Congratulations tom🥳💐💐 !! you passed the exam. You got " + tomsResult + " out of 100. So your Grad is 'D' ") ; 64 | } 65 | 66 | else if( 50 <= tomsResult && tomsResult < 60 ){ 67 | console.log("Congratulations Tom🥳💐💐 !! you passed the exam. You got " + tomsResult + " out of 100. So your Grad is 'C' ") ; 68 | } 69 | 70 | else if( 60 <= tomsResult && tomsResult < 80 ){ 71 | console.log("Congratulations Tom🥳💐💐 !! you passed the exam. You got " + tomsResult + " out of 100. So your Grad is 'B' ") ; 72 | } 73 | 74 | else { 75 | console.log("Congratulations Tom, It's Awesome🥳💖💕 !! you are the Best. You got " + tomsResult + " out of 100. So your Grad is 'A' ") ; 76 | } 77 | 78 | 79 | /* ----------------------------- 80 | For Jane's Result 81 | --------------------------------- */ 82 | 83 | if( janesResult <= 39){ 84 | console.log("Sorry !! Jane😞😥 you failed in the exam. You got " + janesResult + " out of 100. So your Grad is 'F' ") ; 85 | } 86 | 87 | else if( 40 <= janesResult && janesResult < 50 ){ 88 | console.log("Congratulations Jane🥳💐💐 !! you passed the exam. You got " + janesResult + " out of 100. So your Grad is 'D' ") ; 89 | } 90 | 91 | else if( 50 <= janesResult && janesResult < 60 ){ 92 | console.log("Congratulations Jane🥳💐💐 !! you passed the exam. You got " + janesResult + " out of 100. So your Grad is 'C' ") ; 93 | } 94 | 95 | else if( 60 <= janesResult && janesResult < 80 ){ 96 | console.log("Congratulations Jane🥳💐💐 !! you passed the exam. You got " + janesResult + " out of 100. So your Grad is 'B' ") ; 97 | } 98 | 99 | else { 100 | console.log("Congratulations Jane, It's Awesome🥳💖💕 !! you are the Best. You got " + janesResult + " out of 100. So your Grad is 'A' ") ; 101 | } 102 | 103 | /* ----------------------------- 104 | For Peter's Result 105 | --------------------------------- */ 106 | 107 | if( petersResult <= 39){ 108 | console.log("Sorry !! Peter😞😥 you failed in the exam. You got " + petersResult + " out of 100. So your Grad is 'F' ") ; 109 | } 110 | 111 | else if( 40 <= petersResult && petersResult < 50 ){ 112 | console.log("Congratulations Peter🥳💐💐 !! you passed the exam. You got " + petersResult + " out of 100. So your Grad is 'D' ") ; 113 | } 114 | 115 | else if( 50 <= petersResult && petersResult < 60 ){ 116 | console.log("Congratulations Peter🥳💐💐 !! you passed the exam. You got " + petersResult + " out of 100. So your Grad is 'C' ") ; 117 | } 118 | 119 | else if( 60 <= petersResult && petersResult < 80 ){ 120 | console.log("Congratulations Peter🥳💐💐 !! you passed the exam. You got " + petersResult + " out of 100. So your Grad is 'B' ") ; 121 | } 122 | 123 | else { 124 | console.log("Congratulations Peter, It's Awesome🥳💖💕 !! you are the Best. You got " + petersResult + " out of 100. So your Grad is 'A' ") ; 125 | } 126 | 127 | 128 | 129 | /* ----------------------------- 130 | For John's Result 131 | --------------------------------- */ 132 | 133 | if( johnsResult <= 39){ 134 | console.log("Sorry !! Johns😞😥 you failed in the exam. You got " + johnsResult + " out of 100. So your Grad is 'F' ") ; 135 | } 136 | 137 | else if( 40 <= johnsResult && johnsResult < 50 ){ 138 | console.log("Congratulations Johns🥳💐💐 !! you passed the exam. You got " + johnsResult + " out of 100. So your Grad is 'D' ") ; 139 | } 140 | 141 | else if( 50 <= johnsResult && johnsResult < 60 ){ 142 | console.log("Congratulations John🥳💐💐 !! you passed the exam. You got " + johnsResult + " out of 100. So your Grad is 'C' ") ; 143 | } 144 | 145 | else if( 60 <= johnsResult && johnsResult < 80 ){ 146 | console.log("Congratulations John🥳💐💐 !! you passed the exam. You got " + johnsResult + " out of 100. So your Grad is 'B' ") ; 147 | } 148 | 149 | else { 150 | console.log("Congratulations John, It's Awesome🥳💖💕 !! you are the Best. You got " + johnsResult + " out of 100. So your Grad is 'A' ") ; 151 | } 152 | 153 | 154 | -------------------------------------------------------------------------------- /challanges1-to-72/problem5/problem5.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var aliyasResult = 95; 4 | var daliyasResult = 66; 5 | var saliyasResult = 80; 6 | var milyasResult = 59; 7 | var liliyasResult = 47; 8 | var jalaiyasResult = 77; 9 | 10 | 11 | 12 | /* --------------------------------------------- 13 | Aliya's Grade 14 | ---------------------------------------------- */ 15 | if( 50 > aliyasResult){ 16 | console.log("Aliya You got " + aliyasResult + ", unfortunately you failed in this Exam !!!"); 17 | } 18 | 19 | else if ( 50 <= aliyasResult && aliyasResult < 60){ 20 | console.log("Congratulations Aliya!!! You got " + aliyasResult + ". And you Grade is 'D' "); 21 | } 22 | 23 | 24 | else if ( 60 <= aliyasResult && aliyasResult < 70){ 25 | console.log("Congratulations Aliya!!! You got " + aliyasResult + ". And you Grade is 'C' "); 26 | } 27 | 28 | else if ( 70 <= aliyasResult && aliyasResult < 80){ 29 | console.log("Congratulations Aliya!!! You got " + aliyasResult + ". And you Grade is 'B' "); 30 | } 31 | 32 | else if ( 80 <= aliyasResult && aliyasResult < 90){ 33 | console.log("Congratulations Aliya!!! You got " + aliyasResult + ". And you Grade is 'A' "); 34 | } 35 | 36 | else { 37 | console.log("Wow 😲😲😲 Wonderful 💖💐🎉 Aliya !!! You got " + aliyasResult + ". And you Grade is 'A+' "); 38 | } 39 | 40 | 41 | /* --------------------------------------------- 42 | Daliya's Grade 43 | ---------------------------------------------- */ 44 | if( 50 > daliyasResult){ 45 | console.log("Daliya You got " + daliyasResult + ", unfortunately you failed in this Exam !!!"); 46 | } 47 | 48 | else if ( 50 <= daliyasResult && daliyasResult < 60){ 49 | console.log("Congratulations Daliya!!! You got " + daliyasResult + ". And you Grade is 'D' "); 50 | } 51 | 52 | 53 | else if ( 60 <= daliyasResult && daliyasResult < 70){ 54 | console.log("Congratulations Daliya!!! You got " + daliyasResult + ". And you Grade is 'C' "); 55 | } 56 | 57 | else if ( 70 <= daliyasResult && daliyasResult < 80){ 58 | console.log("Congratulations Daliya!!! You got " + daliyasResult + ". And you Grade is 'B' "); 59 | } 60 | 61 | else if ( 80 <= daliyasResult && daliyasResult < 90){ 62 | console.log("Congratulations Daliya!!! You got " + daliyasResult + ". And you Grade is 'A' "); 63 | } 64 | 65 | else { 66 | console.log("Wow 😲😲😲 Wonderful 💖💐🎉 Daliya !!! You got " + daliyasResult + ". And you Grade is 'A+' "); 67 | } 68 | 69 | 70 | 71 | /* --------------------------------------------- 72 | Saliya's Grade 73 | ---------------------------------------------- */ 74 | if( 50 > saliyasResult){ 75 | console.log("Saliya You got " + saliyasResult + ", unfortunately you failed in this Exam !!!"); 76 | } 77 | 78 | else if ( 50 <= saliyasResult && saliyasResult < 60){ 79 | console.log("Congratulations Saliya!!! You got " + saliyasResult + ". And you Grade is 'D' "); 80 | } 81 | 82 | 83 | else if ( 60 <= saliyasResult && saliyasResult < 70){ 84 | console.log("Congratulations Saliya!!! You got " + saliyasResult + ". And you Grade is 'C' "); 85 | } 86 | 87 | else if ( 70 <= saliyasResult && saliyasResult < 80){ 88 | console.log("Congratulations Saliya!!! You got " + saliyasResult + ". And you Grade is 'B' "); 89 | } 90 | 91 | else if ( 80 <= saliyasResult && saliyasResult < 90){ 92 | console.log("Congratulations Saliya!!! You got " + saliyasResult + ". And you Grade is 'A' "); 93 | } 94 | 95 | else { 96 | console.log("Wow 😲😲😲 Wonderful 💖💐🎉 Saliya !!! You got " + saliyasResult + ". And you Grade is 'A+' "); 97 | } 98 | 99 | 100 | 101 | /* --------------------------------------------- 102 | Maliya's Grade 103 | ---------------------------------------------- */ 104 | if( 50 > milyasResult){ 105 | console.log("Maliya You got " + milyasResult + ", unfortunately you failed in this Exam !!!"); 106 | } 107 | 108 | else if ( 50 <= milyasResult && milyasResult < 60){ 109 | console.log("Congratulations Maliya!!! You got " + milyasResult + ". And you Grade is 'D' "); 110 | } 111 | 112 | 113 | else if ( 60 <= milyasResult && milyasResult < 70){ 114 | console.log("Congratulations Maliya!!! You got " + milyasResult + ". And you Grade is 'C' "); 115 | } 116 | 117 | else if ( 70 <= milyasResult && milyasResult < 80){ 118 | console.log("Congratulations Maliya!!! You got " + milyasResult + ". And you Grade is 'B' "); 119 | } 120 | 121 | else if ( 80 <= milyasResult && milyasResult < 90){ 122 | console.log("Congratulations Maliya!!! You got " + milyasResult + ". And you Grade is 'A' "); 123 | } 124 | 125 | else { 126 | console.log("Wow 😲😲😲 Wonderful 💖💐🎉 Maliya !!! You got " + milyasResult + ". And you Grade is 'A+' "); 127 | } 128 | 129 | /* --------------------------------------------- 130 | Laliyas Grade 131 | ---------------------------------------------- */ 132 | if( 50 > liliyasResult){ 133 | console.log("Laliya You got " + liliyasResult + ", unfortunately you failed in this Exam !!!"); 134 | } 135 | 136 | else if ( 50 <= liliyasResult && liliyasResult < 60){ 137 | console.log("Congratulations Laliya!!! You got " + liliyasResult + ". And you Grade is 'D' "); 138 | } 139 | 140 | 141 | else if ( 60 <= liliyasResult && liliyasResult < 70){ 142 | console.log("Congratulations Laliya!!! You got " + liliyasResult + ". And you Grade is 'C' "); 143 | } 144 | 145 | else if ( 70 <= liliyasResult && liliyasResult < 80){ 146 | console.log("Congratulations Laliya!!! You got " + liliyasResult + ". And you Grade is 'B' "); 147 | } 148 | 149 | else if ( 80 <= liliyasResult && liliyasResult < 90){ 150 | console.log("Congratulations Laliya!!! You got " + liliyasResult + ". And you Grade is 'A' "); 151 | } 152 | 153 | else { 154 | console.log("Wow 😲😲😲 Wonderful 💖💐🎉 Laliya !!! You got " + liliyasResult + ". And you Grade is 'A+' "); 155 | } 156 | 157 | 158 | /* --------------------------------------------- 159 | Jalaiya's Grade 160 | ---------------------------------------------- */ 161 | if( 50 > jalaiyasResult){ 162 | console.log("Jalaiya You got " + jalaiyasResult + ", unfortunately you failed in this Exam !!!"); 163 | } 164 | 165 | else if ( 50 <= jalaiyasResult && jalaiyasResult < 60){ 166 | console.log("Congratulations Jalaiya!!! You got " + jalaiyasResult + ". And you Grade is 'D' "); 167 | } 168 | 169 | 170 | else if ( 60 <= jalaiyasResult && jalaiyasResult < 70){ 171 | console.log("Congratulations Jalaiya!!! You got " + jalaiyasResult + ". And you Grade is 'C' "); 172 | } 173 | 174 | else if ( 70 <= jalaiyasResult && jalaiyasResult < 80){ 175 | console.log("Congratulations Jalaiya!!! You got " + jalaiyasResult + ". And you Grade is 'B' "); 176 | } 177 | 178 | else if ( 80 <= jalaiyasResult && jalaiyasResult < 90){ 179 | console.log("Congratulations Jalaiya!!! You got " + jalaiyasResult + ". And you Grade is 'A' "); 180 | } 181 | 182 | else { 183 | console.log("Wow 😲😲😲 Wonderful 💖💐🎉 Jalaiya !!! You got " + jalaiyasResult + ". And you Grade is 'A+' "); 184 | } --------------------------------------------------------------------------------