├── Arrays ├── arr.js └── arr2.js ├── Challenges └── 01_Chellenges.js ├── DSA ├── 1-1-24 │ └── array.js ├── 12-1-24 │ ├── stackReverse.js │ └── stackReverseinclass.js ├── 17-1-24 │ └── binarysearch.js ├── 18-1-24 │ ├── findfrequencyofeachelement.js │ ├── findminimumelementinarray.js │ ├── oddandevenelementinarray.js │ ├── peakelementinanarray.js │ └── twoelementinsetinarray.js ├── 19-12-23 │ ├── maxvalue.js │ └── sumarray.js ├── 2-1-24 │ ├── MergeSort.js │ ├── marg.js │ └── mergesortshiftmethod.js ├── 22-12-23 │ ├── leap.js │ └── local │ │ ├── admin │ │ └── admin.html │ │ ├── login.html │ │ └── user │ │ └── user.html ├── 23-1-24 │ ├── kadane.js │ └── quicksort.js ├── 25-12-23 │ ├── apinavbra.html │ └── todolist.html ├── 26-12-23 │ ├── arrinset.html │ └── arrinset.js ├── 27-12-23 │ └── loop.js ├── 28-12-23 │ ├── selectionsort.js │ └── sumindexfind.js ├── 29-1-24 │ ├── linklist.html │ └── linklist.js ├── 29-12-23 │ └── bubble.js ├── 8-1-24 │ ├── stack.js │ └── stackinclass.js └── 9-1-24 │ └── queue.js ├── Detailed Js ├── 01_basics │ ├── 01_variables.js │ ├── 02_dataTypes.js │ ├── 03_conversionOperation.js │ ├── 04_comparision.js │ ├── 05_strings.js │ ├── 06_nums_and_math.js │ ├── 07_datesinJs.js │ └── datatypes-summary.js ├── 02_basics │ ├── 01_arrays.js │ ├── 02_array.js │ ├── 03_objects.js │ └── 04_objects.js ├── 03_basics │ ├── 01_functions.js │ ├── 02_scopes.js │ ├── 03_arrow.js │ └── 04_iife.js ├── 04_control_flow │ ├── one.js │ ├── switch.js │ └── truthy.js ├── 05_iterations │ ├── five.js │ ├── four.js │ ├── nine.js │ ├── one.js │ ├── seven.js │ ├── six.js │ ├── three.js │ └── two.js ├── 06_dom │ ├── four.html │ ├── one.html │ ├── three.html │ └── two.html ├── 07_projects │ └── projectsset1.md ├── 08_events │ ├── eventbasics.js │ ├── one.html │ ├── three.html │ └── two.html ├── 09_advance_one │ ├── ApiRequest.html │ ├── promise.js │ └── promises.js ├── 10_classes_and_oop │ ├── Object.js │ ├── Prototype.js │ ├── bind.html │ ├── call.js │ ├── getter_setter.js │ ├── inheritance.js │ ├── mathpi.js │ ├── myClasses.js │ ├── notes.md │ ├── object_get_set.js │ ├── oop.js │ ├── properties_get_set.js │ └── staticprop.js └── 11_fun_with_js │ └── closure.html ├── Lecture ├── Object in Js │ ├── index.html │ ├── loop.js │ └── method.js └── Quets Task │ ├── index.html │ ├── qoutes-app.js │ ├── quote-slider.js │ └── slider.html ├── Logical-Tasks ├── armstrong_num.js ├── decimal.js ├── fibonacci.js ├── find_arm.js ├── interview_tasks │ ├── logic.html │ ├── pattern.html │ ├── pattern.js │ └── task_01.js ├── oop.html ├── patterns.js ├── pelindrome_num.js ├── print.js ├── remove_dup.js └── task.html └── Practice └── OOP ├── calc.js ├── constructor.html ├── constructor.js ├── inheritance.html ├── inheritance.js └── tipCalc.html /Arrays/arr.js: -------------------------------------------------------------------------------- 1 | // Date: 10/10/2021 2 | // Note: Sum of Array Elements 3 | // Problem: Given an array of integers, return the sum of all elements in the array. 4 | // Example: 5 | // arr = [1, 2, 3, 4, 5] 6 | // arr2 = [6,6,3] 7 | 8 | 9 | // let arr = [1, 2, 3, 4, 5, 5, 5, 5, 5]; 10 | 11 | // let sumArray = (arr) => { 12 | // let arr2 = []; 13 | // let len = arr.length; // 9 14 | // let mid = Math.floor(len / 2); //5 15 | 16 | // for (let i = 0; i <= mid; i++) { 17 | // if (i === len - i - 1) { 18 | // arr2[arr2.length] = arr[i]; 19 | // } else if (i < len - i - 1) { 20 | // arr2[arr2.length] = arr[i] + arr[len - i - 1]; 21 | // } 22 | // } 23 | 24 | // return arr2; 25 | // } 26 | 27 | // console.log(sumArray(arr)); 28 | 29 | // ---------------------------------------------------------------------------------------------------------------- 30 | 31 | // Find The Second Largest (Distinct) Element In An Array 32 | // Given an array of integers, return the second largest element in the array.If the array has less than two distinct elements, return null. 33 | // Example: 34 | // arr = [1, 2, 3, 4, 5] 35 | // 4 Second Largest 36 | 37 | 38 | // --******** Using For Loop Less Time Complexity *********-- 39 | 40 | // let arr = [1,2,3,4,5,5,5,6]; 41 | 42 | // let sLargest = (arr) => { 43 | // let l = Number.NEGATIVE_INFINITY; 44 | // let sl = Number.NEGATIVE_INFINITY; 45 | 46 | // for(let i=0; i < arr.length;i++){ 47 | // if(arr[i] > l){ 48 | // sl = l; 49 | // l = arr[i] 50 | // }else if(arr[i] != l && arr[i] > sl){ 51 | // sl = arr[i] 52 | // } 53 | // } 54 | // console.log(l) 55 | // console.log(sl) 56 | // } 57 | // sLargest(arr) 58 | // ---------------------------------------------------------------------------------------------------------------- 59 | // --******** Using Methods *********-- 60 | 61 | // let arr = [10,10,9]; 62 | 63 | // let sLargest = (arr) => { 64 | // let uArr = Array.from(new Set(arr)); 65 | 66 | // uArr.sort((a,b) => { 67 | // return b - a; 68 | // }) 69 | 70 | // if(uArr.length >= 2){ 71 | // return uArr[1] 72 | // }else{ 73 | // return -1 74 | // } 75 | // } 76 | // console.log(sLargest(arr)) 77 | 78 | // ---------------------------------------------------------------------------------------------------------------- 79 | 80 | // Find The Second Smallest Element In An Array 81 | // Given an array of integers, return the second smallest element in the array.If the array has less than two distinct elements, return null. 82 | // Example: 83 | // arr = [1, 2, 3, 4, 5] 84 | // 2 Second Smallest 85 | 86 | // --******** Using For Loop Less Time Complexity *********-- 87 | 88 | // let arr = [1,2,3,4,5,5,5,6]; 89 | 90 | // let sSmallest = (arr) => { 91 | // let sma = Number.POSITIVE_INFINITY; 92 | // let sma2 = Number.POSITIVE_INFINITY; 93 | 94 | // for(let i=0; i < arr.length;i++){ 95 | // if(arr[i] < sma){ 96 | // sma2 = sma; 97 | // sma = arr[i] 98 | // }else if(arr[i] != sma && arr[i] < sma2){ 99 | // sma2 = arr[i] 100 | // } 101 | // } 102 | // console.log(sma) 103 | // console.log(sma2) 104 | // } 105 | // sSmallest(arr) 106 | 107 | // ---------------------------------------------------------------------------------------------------------------- 108 | 109 | // --******** Using Methods *********-- 110 | 111 | // let arr = [10,10,9]; 112 | 113 | // let sSmallest = (arr) => { 114 | // let uArr = Array.from(new Set(arr)); 115 | 116 | // uArr.sort((a,b) => { 117 | // return b - a; 118 | // }) 119 | 120 | // if(uArr.length >= 2){ 121 | // return uArr[1] 122 | // }else{ 123 | // return -1 124 | // } 125 | // } 126 | // console.log(sSmallest(arr)) 127 | 128 | 129 | // ---------------------------------------------------------------------------------------------------------------- 130 | 131 | // Reverce an Array Without using any Prebuilt Function 132 | // Given an array of integers, return the reverse of the array without using any prebuilt functions. 133 | // Example: 134 | // arr = [1, 2, 3, 4, 5] 135 | // [5,4,3,2,1] 136 | 137 | 138 | // --******** Using For Loop Less Time Complexity *********-- 139 | 140 | // let arr = [1, 2, 3, 4, 5]; 141 | // let rev = []; 142 | // let len = arr.length; 143 | 144 | // for (let i = 0; i < len; i++) { 145 | // rev[len - i - 1] = arr[i]; 146 | // } 147 | 148 | // console.log(rev); 149 | 150 | // ---------------------------------------------------------------------------------------------------------------- 151 | 152 | // --******** Using Function *********-- 153 | 154 | // let arr = [1, 2, 3, 4, 5]; 155 | 156 | // let reverseArray = (arr) => { 157 | // let rev = []; 158 | // let len = arr.length; 159 | 160 | // for(let i=0; i< arr.length; i++){ 161 | // rev[len - i - 1] = arr[i]; 162 | // } 163 | // return rev; 164 | // } 165 | // console.log(reverseArray(arr)); 166 | 167 | // ---------------------------------------------------------------------------------------------------------------- 168 | 169 | -------------------------------------------------------------------------------- /Arrays/arr2.js: -------------------------------------------------------------------------------- 1 | // WAP to Remove Duplicate Elements from an array. Without using any prebuilt function. 2 | // Example: 3 | // arr = [1, 2, 2, 2, 3, 2, 3, 4, 4, 4, 5] 4 | // [1,2,3,4,5] 5 | 6 | 7 | 8 | let arr = [1,1,2,2,2, 2, 2, 3, 4, 5, 6, 6, 6]; 9 | let newArr = []; 10 | let k = 0; // Index for newArr 11 | for(let i=0; i result[l]) { 12 | // let temp = result[k]; 13 | // result[k] = result[l]; 14 | // result[l] = temp; 15 | // } 16 | // console.log(result); 17 | // } 18 | // // console.log(array); 19 | // } 20 | // console.log("Sorted array: ", result); 21 | 22 | // second method two array merge 23 | 24 | 25 | 26 | let arr1 = [4,2,6]; 27 | let arr2 = [3,9,5]; 28 | let marg =[] 29 | 30 | for(let i = 0; i < arr1.length; i++){ 31 | marg[i] = arr1[i]; 32 | for(let j = 0; j marg[l]) { 43 | let temp = marg[k]; 44 | marg[k] = marg[l]; 45 | marg[l] = temp; 46 | } 47 | // console.log(marg); 48 | } 49 | // console.log(array); 50 | } 51 | console.log("Sorted array: ", marg); 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /DSA/12-1-24/stackReverse.js: -------------------------------------------------------------------------------- 1 | let stack = "hello jignesh"; 2 | let arr = []; 3 | let head = 0; 4 | console.log("head :- "+head); 5 | let tail = arr.length ; 6 | 7 | function stackempty(stack) { 8 | if (stack == 0) { 9 | console.log(true); 10 | } else { 11 | console.log(false); 12 | for (let i = 0; i < stack.length; i++) { 13 | // arr.push(stack[i]); 14 | arr[arr.length] = stack[i]; 15 | } 16 | console.log(arr); 17 | tail = arr.length ; 18 | console.log("tail:"+tail); 19 | } 20 | } 21 | function arrempty(arr) { 22 | return arr.length === 0 ? true : false; 23 | } 24 | let temp =[]; 25 | 26 | function reversestack(head,tail,arr){ 27 | // console.log(head); 28 | // console.log(tail); 29 | for(let k = head; k < arr.length; k++){ 30 | temp[k] = arr[--tail]; 31 | // temp[k] = arr.pop(); 32 | // arr[head] = temp[k]; 33 | // console.log(tail); 34 | console.log(temp); 35 | // arr[k]=temp[k]; 36 | // console.log(arr); 37 | } 38 | } 39 | function print(temp){ 40 | for(let j=head; j ub) { 8 | return -1; 9 | } 10 | let mid = parseInt((lb + ub) / 2); 11 | if (arr[mid] == n) { 12 | return mid; 13 | } 14 | if (arr[mid] > n) { 15 | return binary(arr, lb, mid - 1, n); 16 | } else { 17 | return binary(arr, mid + 1, ub, n); 18 | } 19 | } 20 | 21 | let result = binary(arr, lb, ub, n); 22 | if (result == -1) { 23 | console.log("Element not found"); 24 | } else { 25 | console.log(`Element is present at index ${result}`); 26 | } 27 | -------------------------------------------------------------------------------- /DSA/18-1-24/findfrequencyofeachelement.js: -------------------------------------------------------------------------------- 1 | class frequency { 2 | constructor(){ 3 | this.array = [1,5,3,8,8,1,2,6,4,2,2,6,7,5,5,4,4]; 4 | this.count={}; 5 | } 6 | start() { 7 | for(let i=0;i this.maxpeek) { 9 | this.maxpeek = this.array[i]; 10 | } 11 | } 12 | console.log(`this is max value peek = ${this.maxpeek}`); 13 | } 14 | } 15 | 16 | let peekelement = new peek(); 17 | peekelement.findpeek(); 18 | -------------------------------------------------------------------------------- /DSA/18-1-24/twoelementinsetinarray.js: -------------------------------------------------------------------------------- 1 | let arr = [4, 5, 3, 6, 8, 7, 2, 9]; 2 | let position = 4; 3 | let value1 =55; 4 | let value2 =66; 5 | console.log(arr); 6 | for (let i = arr.length; i >= position; i--) { 7 | arr[i] = arr[i - 1]; 8 | arr[i+1] = arr[i - 1]; 9 | } 10 | arr[position - 1] = value1; 11 | arr[position] = value2; 12 | console.log(arr); 13 | -------------------------------------------------------------------------------- /DSA/19-12-23/maxvalue.js: -------------------------------------------------------------------------------- 1 | // const arr = [1,2,3,4,5,6]; 2 | // let max = arr[0]; 3 | // for(let i = 0; i max){ 5 | // max = arr[i]; 6 | // console.log(arr[i]); 7 | // } 8 | // } 9 | // console.log(max+"this is a max"); 10 | 11 | const arr1 = [1,2,0,4,5,6]; 12 | let min = arr1[0]; 13 | for(let i = 0; i=r){ 66 | return; 67 | } 68 | let m = l + parseInt((r-l)/2); 69 | mergeSort(arr,l,m); 70 | mergeSort(arr,m+1,r); 71 | merge(arr,l,m,r); 72 | } 73 | 74 | // Function to print an array 75 | function printArray( A, size) 76 | { 77 | for (let i = 0; i < size; i++) 78 | console.log( A[i] ); 79 | } 80 | 81 | 82 | let arr = [ 12, 11, 13, 5, 6, 7 ]; 83 | let arr_size = arr.length; 84 | 85 | console.log( "Given array is "); 86 | printArray(arr, arr_size); 87 | 88 | mergeSort(arr, 0, arr_size - 1); 89 | 90 | console.log( "Sorted array is "); 91 | printArray(arr, arr_size); 92 | 93 | // This code is contributed by SoumikMondal 94 | -------------------------------------------------------------------------------- /DSA/2-1-24/marg.js: -------------------------------------------------------------------------------- 1 | const arr = [1,3,5,2,4,6]; 2 | let si = 0; 3 | let ei = arr.length - 1; 4 | 5 | function divided(array, si, ei) { 6 | let mi = parseInt((array.length - 1) / 2); 7 | 8 | if (array.length < 2) { 9 | return; 10 | } 11 | 12 | //left array 13 | const array1 = []; 14 | for (let i = si; i <= mi; i++) { 15 | array1.push(array[i]); 16 | } 17 | let lsi = 0; 18 | let lei = array1.length - 1; 19 | console.log(array1, "left"); 20 | 21 | //right array 22 | const array2 = []; 23 | for (let j = mi + 1; j <= ei; j++) { 24 | array2.push(array[j]); 25 | } 26 | let rsi = 0; 27 | let rei = array2.length - 1; 28 | console.log(array2, "rigth"); 29 | 30 | divided(array1, lsi, lei); 31 | divided(array2, rsi, rei); 32 | marg(array1, array2); 33 | } 34 | //merge the two arrays in ascending order 35 | function marg(left, rigth) { 36 | let i = 0; 37 | let j = 0; 38 | // let k = 0; 39 | let newmarg = []; 40 | while (i <= left.length && j <= rigth.length) { 41 | if (left[i] <= rigth[j]) { 42 | newmarg.push(left[i]); 43 | i++; 44 | } else { 45 | newmarg.push(rigth[j]); 46 | j++; 47 | } 48 | } 49 | 50 | console.log(newmarg); 51 | } 52 | divided(arr, si, ei); 53 | -------------------------------------------------------------------------------- /DSA/2-1-24/mergesortshiftmethod.js: -------------------------------------------------------------------------------- 1 | // let array = [6, 7, 3, 4, 9, 2, 8]; 2 | 3 | // function mergesort(array) { 4 | // if (array.length < 2) { 5 | // return array; 6 | // } 7 | // let mid = Math.floor(array.length / 2); 8 | // let left = array.slice(0, mid); 9 | // let right = array.slice(mid); 10 | 11 | // return merge(mergesort(left), mergesort(right)); 12 | // } 13 | // function merge(left, right) { 14 | // let temp = []; 15 | // while (left.length && right.length) { 16 | // if (left[0] <= right[0]) { 17 | // temp.push(left.shift()); 18 | // } else { 19 | // temp.push(right.shift()); 20 | // } 21 | // } 22 | 23 | // // temp = temp.concat(left).concat(right); 24 | // // return temp; 25 | // return [...temp,...left,...right]; 26 | 27 | // } 28 | // const result = mergesort(array); 29 | // console.log(result); 30 | 31 | let array = [6, 7, 3, 4, 9, 2, 8]; 32 | let si = 0; 33 | let ei = array.length - 1; 34 | 35 | function mergesort(array, si, ei) { 36 | if (si >= ei) { 37 | return; 38 | } 39 | let mid = Math.floor((si + ei) / 2); 40 | 41 | //left array 42 | const array1 = []; 43 | for (let i = si; i <= mid; i++) { 44 | array1.push(array[i]); 45 | } 46 | // let lsi = 0; 47 | // let lei = array1.length - 1; 48 | console.log(array1, "left"); 49 | 50 | //right array 51 | const array2 = []; 52 | for (let j = mid + 1; j <= ei; j++) { 53 | array2.push(array[j]); 54 | } 55 | // let rsi = 0; 56 | // let rei = array2.length - 1; 57 | console.log(array2, "rigth"); 58 | 59 | mergesort(array, si, mid); 60 | mergesort(array, mid + 1, ei); 61 | merge(array1,array2); 62 | } 63 | function merge(array1,array2) { 64 | let temp = []; 65 | let i = 0; 66 | let j = 0; 67 | let k = 0; 68 | 69 | while (array1.length && array2.length) { 70 | if (array1[i] >= array2[j]) { 71 | // temp.push(array1.shift()); 72 | temp[k] = array1[i]; 73 | i++; 74 | } else { 75 | // temp.push(array2.shift()); 76 | temp[k] = array2[j]; 77 | j++ 78 | } 79 | k++; 80 | } 81 | 82 | while (i < array1.length) { 83 | temp[k] = array1[i]; 84 | i++; 85 | k++; 86 | } 87 | 88 | while (j < array2.length) { 89 | temp[k] = array2[j]; 90 | j++; 91 | k++; 92 | } 93 | 94 | 95 | } 96 | const result = mergesort(array, si, ei); 97 | console.log(result); 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /DSA/22-12-23/leap.js: -------------------------------------------------------------------------------- 1 | let arr = []; 2 | for(let i = 2010; i<=2020; i++){ 3 | if(i % 4 ==0){ 4 | // console.log(i); 5 | // arr += i; 6 | arr.push(i) 7 | } 8 | } 9 | console.log(arr+" leap yearn"); 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /DSA/22-12-23/local/admin/admin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | admin 7 | 21 | 22 | 23 | 28 |

admin page

29 | 30 | 31 | 32 |
33 |
34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
productnameprice
43 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /DSA/22-12-23/local/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | 12 | 28 | 29 | -------------------------------------------------------------------------------- /DSA/22-12-23/local/user/user.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | user 7 | 21 | 22 | 23 | 28 |

user page

29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
productnameprice
38 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /DSA/23-1-24/kadane.js: -------------------------------------------------------------------------------- 1 | // kadane time complexity = O(n) first method 2 | let array = [5,4,-2,6,-3,7,9,-1,8]; 3 | // let array = [-2, -3, 4, -1, -2, 1, 5, -3]; 4 | let sum = 0; 5 | let max =array[0]; 6 | 7 | for(let i=0; i 2 | 3 | 4 | 5 | 6 | product 7 | 13 | 18 | 23 | 28 | 57 | 58 | 59 | 65 | 66 | 67 |
68 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /DSA/25-12-23/todolist.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | todolist 7 | 8 | 14 | 19 | 24 | 29 | 72 | 73 | 74 | 80 | 81 |
82 | 83 | 110 | 111 | -------------------------------------------------------------------------------- /DSA/26-12-23/arrinset.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | arrinset 7 | 8 | 9 | 10 | 11 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /DSA/26-12-23/arrinset.js: -------------------------------------------------------------------------------- 1 | const array = [1, 2, 3, 4, 5, 6, 7, 8, 9]; 2 | let position = 4; 3 | let value = 30; 4 | 5 | for (let i = array.length; i >= position; i--) { 6 | array[i] = array[i - 1]; 7 | } 8 | array[position ] = value; 9 | console.log(array); 10 | 11 | -------------------------------------------------------------------------------- /DSA/27-12-23/loop.js: -------------------------------------------------------------------------------- 1 | console.log("jignddb"); 2 | // for(let i = 1; i<=10; i++){ 3 | // console.log(i); 4 | // } 5 | 6 | // for (let i = 10; i >= 1; i--) { 7 | // console.log(i); 8 | // } 9 | 10 | // for (let i = 1; i <= 10; i++) { 11 | // console.log(i); 12 | // } 13 | 14 | // for (let i = 10; i <= 20; i++) { 15 | // console.log(i); 16 | // } 17 | 18 | // for (let i = 1; i <= 10; i++) { 19 | // console.log(i); 20 | // } 21 | 22 | // for (let i = 50; i >=1; i--) { 23 | // console.log(i); 24 | // } 25 | // for (let i = 1; i <= 10; i++) { 26 | // console.log(i); 27 | // } 28 | // for(let x = 100 ; x >= 1; x--) 29 | // { 30 | // console.log(x); 31 | // } 32 | 33 | // for (let x = 8; x <= 88; x += 8) { 34 | // console.log(x); 35 | // } 36 | 37 | // for (let x = 2; x <= 30; x += 5) { 38 | // console.log(x); 39 | // } 40 | 41 | // for (let x = 66; x >= 0; x -= 6) { 42 | // console.log(x); 43 | // } 44 | 45 | // let sum=0; 46 | // for(let x=1;x<=50;++x) 47 | // { 48 | // sum = sum + x; 49 | // } 50 | // console.log(sum); 51 | 52 | // let sum=0; 53 | // for(let x=1;x<=50;x++) 54 | // { 55 | // sum = sum + x; 56 | // } 57 | // console.log(sum); 58 | 59 | // for (let x = 66; x >= 0; x -= 6) { 60 | // console.log(x); 61 | // } 62 | 63 | 64 | 65 | // const subjects = ["Maths", "Science", "Polity", "History"]; 66 | // let i = 0; 67 | // let len = subjects.length; 68 | // let gfg = ""; 69 | // for (; i < len;) { 70 | // gfg += subjects[i]; 71 | // //can be increased inside loop 72 | // i++; 73 | // } 74 | // console.log(gfg) 75 | // for(let i = 1 ; i <=50; i++ ){ 76 | // console.log(i); 77 | 78 | // } 79 | for(let i = 50 ; i >=25; i--){ 80 | console.log(i); 81 | } 82 | 83 | -------------------------------------------------------------------------------- /DSA/28-12-23/selectionsort.js: -------------------------------------------------------------------------------- 1 | let array = [64, 25, 12, 22, 11]; 2 | 3 | for (let i = 0; i < array.length; i++) { 4 | console.log(array + " mina"); 5 | for (let j = i + 1; j < array.length; j++) { 6 | if (array[i] > array[j]) { 7 | let temp = array[i]; 8 | array[i] = array[j]; 9 | array[j] = temp; 10 | } 11 | console.log(array); 12 | } 13 | console.log(array); 14 | } 15 | console.log("Sorted array: ", array); -------------------------------------------------------------------------------- /DSA/28-12-23/sumindexfind.js: -------------------------------------------------------------------------------- 1 | let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]; 2 | let sum = 0; 3 | for (i = 0; i < arr.length; i++) { 4 | console.log(i + "=" + arr[i]); 5 | // sum += arr[i]; 6 | sum = sum + arr[i]; 7 | } 8 | console.log("sum = " + sum); 9 | 10 | let target = 9; 11 | console.log("TARGET = " + target); 12 | for (i = 0; i < arr.length; i++) { 13 | for (j = 1; j < arr.length; j++) { 14 | if (arr[i] + arr[i + j] == target) { 15 | let arr1 = [i, i + j]; 16 | console.log("INDEX NO :-" + arr1 + "
"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /DSA/29-1-24/linklist.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | linked list 7 | 8 | 9 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /DSA/29-1-24/linklist.js: -------------------------------------------------------------------------------- 1 | class Node { 2 | constructor(data) { 3 | this.head ={ 4 | value:data, 5 | next:null, 6 | }; 7 | this.tail = this.head; 8 | this.size = 1; 9 | } 10 | 11 | add(data){ 12 | const node ={ 13 | value:data, 14 | next:null, 15 | } 16 | 17 | console.log(node); 18 | this.tail.next = node; 19 | this.tail = node; 20 | this.size +=1; 21 | } 22 | print(){ 23 | let count = 0; 24 | let current = this.head; 25 | 26 | while(count < this.size){ 27 | console.log(current,"current"); 28 | current = current.next; 29 | count++; 30 | } 31 | } 32 | delete(number) { 33 | if (this.head == null || number > this.size) return false; 34 | if (number === 0) { 35 | this.head = this.head.next; 36 | this.tail.next = this.head; 37 | } else { 38 | let previews = null; 39 | let currents = this.head; 40 | let index = 0; 41 | while (index++ < number) { 42 | previews = currents; 43 | currents = currents.next; 44 | } 45 | previews.next = currents.next; 46 | if (currents.next == null) { 47 | this.tail = previews; 48 | } 49 | } 50 | } 51 | } 52 | const node = new Node(50); 53 | node.add(60); 54 | node.add(70); 55 | node.add(80); 56 | node.add(90); 57 | node.print(); 58 | node.delete(2) 59 | console.log(node); 60 | 61 | -------------------------------------------------------------------------------- /DSA/29-12-23/bubble.js: -------------------------------------------------------------------------------- 1 | let arr = [5, 3, 9, 8, 2, 6]; 2 | 3 | for (let i = 0; i < arr.length; i++) { 4 | for (let j = 0; j < arr.length; j++) { 5 | if (arr[j] > arr[j + 1]) { 6 | let temp = arr[j]; 7 | arr[j] = arr[j + 1]; 8 | arr[j + 1] = temp; 9 | } 10 | } 11 | } 12 | console.log(arr); 13 | -------------------------------------------------------------------------------- /DSA/8-1-24/stack.js: -------------------------------------------------------------------------------- 1 | let stackarr = []; 2 | 3 | const stackprint = (stackarr) => { 4 | if (stackarr.length === 0) { 5 | console.log("underflow"); 6 | } else { 7 | for (let i = 0; i < stackarr.length; i++) { 8 | console.log(stackarr); 9 | } 10 | // console.log(stack); 11 | } 12 | }; 13 | const stackadd = (stackarr, element) => { 14 | if (stackarr.length > 4) { 15 | console.log("overflow"); 16 | } else { 17 | stackarr[stackarr.length] = element; 18 | // stackarr.push(element); 19 | } 20 | }; 21 | 22 | const stackremove = (stackarr) => { 23 | if (stackarr.length === 0) { 24 | console.log("Underflow"); 25 | } else { 26 | // let remitem = stackarr.pop(); 27 | // console.log(remitem); 28 | // return stackarr[stackarr.length--]; 29 | stackarr[stackarr.length--]; 30 | } 31 | }; 32 | 33 | // stackadd(stackarr, 2); 34 | // stackadd(stackarr, 4); 35 | // stackadd(stackarr, 5); 36 | // stackadd(stackarr, 6); 37 | // stackadd(stackarr, 7); 38 | // stackadd(stackarr, 8); 39 | stackprint(stackarr); 40 | // stackremove(stackarr); 41 | // stackprint(stackarr); 42 | -------------------------------------------------------------------------------- /DSA/8-1-24/stackinclass.js: -------------------------------------------------------------------------------- 1 | class stack { 2 | constructor() { 3 | this.item = []; 4 | } 5 | push(element) { 6 | // this.item.push(element); 7 | if (this.item.length > 4) { 8 | console.log("overflow"); 9 | } else { 10 | this.item[this.item.length] = element; 11 | } 12 | } 13 | pop() { 14 | if (this.item.length === 0) { 15 | console.log("underflow"); 16 | } else { 17 | return this.item[this.item.length--]; 18 | // let staclpop = this.item[this.item.length--]; 19 | // console.log(staclpop); 20 | } 21 | } 22 | peek() { 23 | return this.item[this.item.length - 1]; 24 | // return this.item[this.item.length - 2]; 25 | // let temp = this.item[this.item.length - 1]; 26 | // console.log(temp); 27 | } 28 | isEmpty() { 29 | return this.item.length == 0; 30 | } 31 | size() { 32 | return this.item.length; 33 | } 34 | clear() { 35 | return this.item = []; 36 | } 37 | } 38 | 39 | let stackarr = new stack(); 40 | stackarr.push(1); 41 | stackarr.push(2); 42 | stackarr.push(3); 43 | stackarr.push(9); 44 | stackarr.push(5); 45 | stackarr.push(6); 46 | console.log(stackarr.item); 47 | stackarr.pop(); 48 | console.log(stackarr.item); 49 | console.log(stackarr.peek()); 50 | console.log(stackarr.isEmpty()); 51 | console.log(stackarr.size()); 52 | stackarr.clear() 53 | console.log(stackarr.item); 54 | -------------------------------------------------------------------------------- /DSA/9-1-24/queue.js: -------------------------------------------------------------------------------- 1 | let queuearr = []; 2 | let head = 0; 3 | let tial = queuearr.length - 1; 4 | let size = 5; 5 | 6 | const queuepush = (queuearr, element) => { 7 | if (queuearr.length > 5) { 8 | console.log("queue is overflow"); 9 | } else { 10 | queuearr[queuearr.length] = element; 11 | console.log(queuearr); 12 | tial = queuearr.length - 1; 13 | } 14 | }; 15 | const queueremove = (head, tial, queuearr) => { 16 | if (head == 0 && tial == -1) { 17 | console.log("the queue is empty"); 18 | } else { 19 | for (let i = queuearr.length; i >= head; i--) { 20 | queuearr[i] = queuearr[i - 1]; 21 | } 22 | queuearr[head - 1] = head--; 23 | console.log(queuearr); 24 | // console.log(queuearr); 25 | // queuearr.shift(); 26 | // console.log(queuearr); 27 | } 28 | }; 29 | // console.log(head,tial); 30 | queuepush(queuearr, 5); 31 | queuepush(queuearr, 6); 32 | queuepush(queuearr, 7); 33 | queuepush(queuearr, 8); 34 | queuepush(queuearr, 9); 35 | queuepush(queuearr, 10); 36 | queuepush(queuearr, 11); 37 | queueremove(head, tial, queuearr); // should print 5 38 | -------------------------------------------------------------------------------- /Detailed Js/01_basics/01_variables.js: -------------------------------------------------------------------------------- 1 | const accountId = 144553 2 | let accountEmail = "hitesh@google.com" 3 | var accountPassword = "12345" 4 | accountCity = "Jaipur" 5 | let accountState; 6 | 7 | // accountId = 2 // not allowed 8 | 9 | accountEmail = "hc@hc.com" 10 | accountPassword = "21212121" 11 | accountCity = "Bengaluru" 12 | 13 | console.log(accountId); 14 | 15 | /* 16 | Prefer not to use var 17 | because of issue in block scope and functional scope 18 | */ 19 | 20 | 21 | console.table([accountId, accountEmail, accountPassword, accountCity, accountState]) -------------------------------------------------------------------------------- /Detailed Js/01_basics/02_dataTypes.js: -------------------------------------------------------------------------------- 1 | "use strict"; // treat all JS code as newer version 2 | 3 | // alert( 3 + 3) // we are using nodejs, not browser 4 | 5 | console.log(3 6 | + 7 | 3) // code readability should be high 8 | 9 | console.log("Hitesh") 10 | 11 | 12 | let name = "hitesh" 13 | let age = 18 14 | let isLoggedIn = false 15 | let state; 16 | 17 | // number => 2 to power 53 18 | // bigint 19 | // string => "" 20 | // boolean => true/false 21 | // null => standalone value 22 | // undefined => 23 | // symbol => unique 24 | 25 | 26 | // object 27 | 28 | console.log(typeof undefined); // undefined 29 | console.log(typeof null); // object 30 | -------------------------------------------------------------------------------- /Detailed Js/01_basics/03_conversionOperation.js: -------------------------------------------------------------------------------- 1 | let score = "Sparky"; 2 | 3 | // console.log(typeof score); 4 | // console.log(typeof (score)); 5 | 6 | // let valueInNumber = Number(score); 7 | // console.log(typeof valueInNumber); 8 | // console.log(valueInNumber); 9 | 10 | 11 | // "33" => 33 12 | // "33abc" => NaN 13 | // true => 1; false => 0 14 | 15 | // let isLoggedIn = "Sparky" 16 | 17 | // let booleanIsLoggedIn = Boolean(isLoggedIn); 18 | // console.log(booleanIsLoggedIn); 19 | 20 | // 1 => true; 0 => false 21 | // "" => false 22 | // "sparky" => true 23 | 24 | // let someNumber = 33 25 | 26 | // let stringNumber = String(someNumber) 27 | // console.log(stringNumber); 28 | // console.log(typeof stringNumber); 29 | // console.log(typeof someNumber); 30 | 31 | 32 | // *********************** Operations *********************** 33 | 34 | // let value = 3 35 | // let negValue = value++ 36 | // console.log(negValue); 37 | // console.log(value); 38 | 39 | // console.log(2+2); 40 | // console.log(2-2); 41 | // console.log(2*2); 42 | // console.log(2**5); 43 | // console.log(2/3); 44 | // console.log(2%3); 45 | 46 | // let str1 = "hello" 47 | // let str2 = " sparky" 48 | 49 | // let str3 = str1 + str2 50 | // console.log(str3); 51 | // console.log(typeof str3); 52 | 53 | // console.log("1" + 2); 54 | // console.log(1 + "2"); 55 | // console.log("1" + 2 + 2); 56 | // console.log(1 + 2 + "2"); 57 | 58 | // console.log( (3 + 4) * 5 % 3); 59 | 60 | // console.log(+true); 61 | // console.log(+""); 62 | 63 | // let num1, num2, num3 64 | 65 | // num1 = num2 = num3 = 2 + 2 66 | 67 | // console.log(num1); 68 | 69 | 70 | // let gameCounter = 100 71 | // ++gameCounter; 72 | // console.log(gameCounter); 73 | 74 | // link to study 75 | // https://tc39.es/ecma262/multipage/abstract-operations.html#sec-type-conversion -------------------------------------------------------------------------------- /Detailed Js/01_basics/04_comparision.js: -------------------------------------------------------------------------------- 1 | // console.log(2 > "1"); 2 | // console.log(2 >= 1); 3 | // console.log(2 < 1); 4 | // console.log(2 == 1); 5 | // console.log(2 != 1); 6 | 7 | 8 | // console.log("2" > 1); 9 | // console.log("02" > 1); 10 | 11 | // console.log(null > 0); 12 | // console.log(null < 0); 13 | // console.log(null == 0); 14 | // console.log(null >= 0); 15 | 16 | // console.log(undefined == 0); 17 | // console.log(undefined > 0); 18 | // console.log(undefined < 0); 19 | 20 | // === 21 | 22 | // console.log("2" == 2); 23 | // console.log("2" === 2); -------------------------------------------------------------------------------- /Detailed Js/01_basics/05_strings.js: -------------------------------------------------------------------------------- 1 | // const name = "Sparky " 2 | // const repoCount = 50 3 | 4 | // console.log(name + repoCount + " theCoder"); 5 | 6 | // console.log(`Hello my name is ${name} and my repo count is ${repoCount}`); 7 | 8 | const gameName = new String('call-Of-Duty'); 9 | 10 | // console.log(gameName[1]); 11 | // console.log(gameName); 12 | 13 | // console.log(gameName.slice(4, gameName.length)); 14 | 15 | // console.log(gameName.length); 16 | // console.log(gameName.toUpperCase()); 17 | // console.log(gameName.charAt(8)); 18 | // console.log(gameName.indexOf('t')); 19 | 20 | // const newString = gameName.substring(0,7); 21 | // console.log(newString); 22 | 23 | // const anotherString = gameName.slice(-11, 4); 24 | // console.log(anotherString); 25 | 26 | // const newStringOne = " Sparky " 27 | // console.log(newStringOne); 28 | // console.log(newStringOne.trim()); 29 | 30 | const url = "https://Spark%20y.com/Sparky%20Tdm" 31 | 32 | // console.log(url.replace('%20', '_')); 33 | 34 | console.log(url.includes('.co')); 35 | 36 | console.log(gameName.split('-')); -------------------------------------------------------------------------------- /Detailed Js/01_basics/06_nums_and_math.js: -------------------------------------------------------------------------------- 1 | // const score = 400 2 | // console.log(score); 3 | 4 | const balance = new Number(100) 5 | // console.log(balance); 6 | 7 | // console.log(balance.toString().length); 8 | 9 | // Add mathematical decimals------------------------------------------- 10 | // console.log(balance.toFixed(2)); 11 | 12 | // const otherNumber = 123.8966 13 | 14 | // Give a value acording to rule of maths------------------------------ 15 | 16 | // console.log(otherNumber.toPrecision(3)); 17 | 18 | // const hundreds = 1000000 19 | // Give a local string according to cuntries countation ex en_IN for indian value---------------------- 20 | // console.log(hundreds.toLocaleString('en-IN')); 21 | 22 | // +++++++++++++ Maths +++++++++++++++++++++++++++++ 23 | 24 | // console.log(Math); 25 | 26 | // Return a Absolute(+) value 27 | 28 | // console.log(Math.abs(-4)); 29 | 30 | // round of with maths rule to normal number from decimal------------------ 31 | 32 | // console.log(Math.round(4.6)); 33 | 34 | // console.log(Math.ceil(4.2)); 35 | 36 | // Round up in Lovest value------------------------------- 37 | 38 | // console.log(Math.floor(4.9)); 39 | // console.log(Math.floor([])); 40 | // console.log(Math.min(4, 3, 6, 8)); 41 | // console.log(Math.max(4, 3, 6, 8)); 42 | 43 | // give an value between 0 to 1----------------------- 44 | 45 | // console.log(Math.random()); 46 | // console.log((Math.random()*10) + 1); 47 | // console.log(Math.floor(Math.random()*10)); 48 | 49 | const min = 10 50 | const max = 20 51 | 52 | console.log(Math.floor(Math.random() * (max - min + 1)) + min); -------------------------------------------------------------------------------- /Detailed Js/01_basics/07_datesinJs.js: -------------------------------------------------------------------------------- 1 | // Dates 2 | 3 | // let myDate = new Date(); 4 | // console.log(myDate.toString()); 5 | // console.log(myDate.toDateString()); 6 | // console.log(myDate.toLocaleString()); 7 | // console.log(typeof myDate); 8 | // console.log(typeof Date()); 9 | 10 | // let myCreatedDate = new Date(2023, 0, 23) 11 | // let myCreatedDate = new Date(2023, 0, 23, 5, 3) 12 | // let myCreatedDate = new Date("2023-01-14") 13 | // let myCreatedDate = new Date("01-14-2023") 14 | // console.log(myCreatedDate.toDateString()); 15 | // console.log(myCreatedDate.toLocaleString()); 16 | 17 | // let myTimeStamp = Date.now() 18 | 19 | // console.log(myTimeStamp); 20 | // console.log(myCreatedDate.getTime()); 21 | // console.log(Math.floor(Date.now()/1000)); 22 | 23 | let newDate = new Date() 24 | // console.log(newDate); 25 | // console.log(newDate.getMonth() + 1); 26 | // console.log(newDate.getDay()); 27 | 28 | console.log(`${newDate.getDay()} and the time `); 29 | 30 | 31 | newDate.toLocaleString('default', { 32 | weekday: "long", 33 | }); -------------------------------------------------------------------------------- /Detailed Js/01_basics/datatypes-summary.js: -------------------------------------------------------------------------------- 1 | // Primitive 2 | 3 | // 7 types : String, Number, Boolearn, null, undefined, Symbol, BigInt 4 | 5 | // const score = 100 6 | // const scoreValue = 100.3 7 | // console.log(typeof scoreValue); 8 | 9 | 10 | // const isLoggedIn = false 11 | // console.log(typeof isLoggedIn); 12 | // const outsideTemp = null 13 | // let userEmail; 14 | // console.log(typeof userEmail); 15 | // console.log(typeof outsideTemp); 16 | 17 | 18 | // const id = Symbol('123') 19 | // const anotherId = Symbol('123') 20 | // console.log(typeof id); 21 | // console.log(typeof anotherId); 22 | 23 | // console.log(id === anotherId); // false 24 | 25 | // const bigNumber = 3456543576654356754n 26 | // console.log(typeof bigNumber); // bigint 27 | 28 | // Reference (Non primitive) 29 | 30 | // Array, Objects, Functions 31 | 32 | // const heros = ["shaktiman", "naagraj", "doga"]; 33 | // let myObj = { 34 | // name: "Sparky", 35 | // age: 22, 36 | // } 37 | 38 | // const myFunction = function(){ 39 | // console.log("Hello world"); 40 | // } 41 | 42 | // console.log(typeof anotherId); 43 | 44 | // https://262.ecma-international.org/5.1/#sec-11.4.3 -------------------------------------------------------------------------------- /Detailed Js/02_basics/01_arrays.js: -------------------------------------------------------------------------------- 1 | // array 2 | 3 | const myArr = [0, 1, 2, 3, 4, 5] 4 | const myHeors = ["shaktiman", "naagraj"] 5 | 6 | // const myArr2 = new Array(1, 2, 3, 4); 7 | // console.log(myArr[1]); 8 | 9 | // Array methods 10 | 11 | // myArr.push(6) 12 | // myArr.push(7) 13 | // console.log(myArr); 14 | 15 | 16 | // myArr.pop() 17 | // console.log(myArr); 18 | 19 | // myArr.unshift(9) 20 | // myArr.shift() 21 | 22 | // console.log(myArr.includes(9)); 23 | // console.log(myArr.indexOf(3)); 24 | 25 | // const newArr = myArr.join() 26 | 27 | // console.log(myArr); 28 | // console.log( newArr); 29 | // console.log( typeof myArr); 30 | // console.log( typeof newArr); 31 | 32 | 33 | 34 | // slice, splice 35 | 36 | // console.log("A ", myArr); 37 | 38 | // const myn1 = myArr.slice(1, 4) 39 | // const myn1 = myArr.slice(0, myArr.length); 40 | // myArr.slice(1, 3) 41 | // console.log(myArr); 42 | 43 | 44 | // console.log(myn1); 45 | // console.log("B ", myArr); 46 | 47 | 48 | // const myn2 = myArr.splice(1, 3, 10 ,20 ,30) 49 | // console.log("C ", myArr); 50 | // console.log(myn2); 51 | -------------------------------------------------------------------------------- /Detailed Js/02_basics/02_array.js: -------------------------------------------------------------------------------- 1 | const marvel_heros = ["thor", "Ironman", "spiderman"] 2 | const dc_heros = ["superman", "flash", "batman"] 3 | 4 | // marvel_heros.push(dc_heros); 5 | 6 | // console.log(marvel_heros); 7 | // console.log(marvel_heros[3][1]); 8 | 9 | // const allHeros = marvel_heros.concat(dc_heros) 10 | // console.log(allHeros); 11 | 12 | // const all_new_heros = [...marvel_heros, ...dc_heros] 13 | 14 | // console.log(all_new_heros); 15 | 16 | // const another_array = [1, 2, 3, [4, 5, 6], 7, [6, 7, [4, 5]]] 17 | // console.log(another_array[5]); 18 | 19 | 20 | // const real_another_array = another_array.flat(Infinity); 21 | // console.log(real_another_array); 22 | 23 | 24 | 25 | // console.log(Array.isArray("Sparky")) 26 | // console.log(Array.from("Sparky")) 27 | // console.log(Array.from({name: "Sparky"})) // interesting 28 | 29 | // let score1 = 100 30 | // let score2 = 200 31 | // let score3 = 300 32 | 33 | // console.log(Array.of(score1, score2, score3)); -------------------------------------------------------------------------------- /Detailed Js/02_basics/03_objects.js: -------------------------------------------------------------------------------- 1 | // singleton 2 | // Object.create 3 | 4 | // object literals 5 | 6 | const mySym = Symbol("key1") 7 | 8 | const JsUser = { 9 | name: "Sparky", 10 | "full name": "Sparky gaming", 11 | [mySym]: "mykey1", 12 | age: 18, 13 | location: "Jaipur", 14 | email: "sparky@google.com", 15 | isLoggedIn: false, 16 | lastLoginDays: ["Monday", "Saturday"] 17 | } 18 | 19 | // console.log(JsUser.email) 20 | // console.log(JsUser["email"]) 21 | // console.log(JsUser["full name"]) 22 | // console.log(JsUser[mySym]) 23 | 24 | // JsUser.email = "sparky@chatgpt.com" 25 | 26 | // cant change a keys value after Object.freez --------------------------------------- 27 | 28 | // Object.freeze(JsUser) 29 | // JsUser.email = "sparky@microsoft.com" 30 | // console.log(JsUser); 31 | 32 | // JsUser.greeting = function(){ 33 | // console.log("Hello JS user"); 34 | // } 35 | // JsUser.greetingTwo = function(){ 36 | // console.log(`Hello JS user, ${JsUser.name}`); 37 | // } 38 | 39 | // console.log(JsUser.greeting()); 40 | // console.log(JsUser.greetingTwo()); -------------------------------------------------------------------------------- /Detailed Js/02_basics/04_objects.js: -------------------------------------------------------------------------------- 1 | // const tinderUser = new Object() 2 | const tinderUser = {} 3 | 4 | tinderUser.id = "123abc" 5 | tinderUser.name = "Sammy" 6 | tinderUser.isLoggedIn = false 7 | 8 | // console.log(tinderUser); 9 | 10 | // const regularUser = { 11 | // email: "some@gmail.com", 12 | // fullname: { 13 | // userfullname: { 14 | // firstname: "sparky", 15 | // lastname: "choudhary" 16 | // } 17 | // } 18 | // } 19 | 20 | // console.log(regularUser.fullname.userfullname.firstname); 21 | 22 | const obj1 = {1: "a", 2: "b"} 23 | const obj2 = {3: "a", 4: "b"} 24 | const obj4 = {5: "a", 6: "b"} 25 | 26 | // const obj3 = { obj1, obj2 } 27 | // const obj3 = Object.assign({}, obj1, obj2, obj4) 28 | 29 | // const obj3 = {...obj1, ...obj2} 30 | // console.log(obj3); 31 | 32 | 33 | // const users = [ 34 | // { 35 | // id: 1, 36 | // email: "h@gmail.com" 37 | // }, 38 | // { 39 | // id: 1, 40 | // email: "hr@gmail.com" 41 | // }, 42 | // { 43 | // id: 1, 44 | // email: "het@gmail.com" 45 | // }, 46 | // ] 47 | 48 | // console.log(users[0].email); 49 | // console.log(users[1].email); 50 | // console.log(users[2].email); 51 | 52 | // console.log(tinderUser); 53 | 54 | // console.log(Object.keys(tinderUser)); 55 | // console.log(Object.values(tinderUser)); 56 | // console.log(Object.entries(tinderUser)); 57 | 58 | // console.log(tinderUser.hasOwnProperty('isLoggedIn')); 59 | 60 | 61 | const course = { 62 | coursename: "js basics ", 63 | price: "999", 64 | courseInstructor: "sparky" 65 | } 66 | 67 | // course.courseInstructor 68 | 69 | const {courseInstructor: instructor} = course 70 | 71 | // console.log({courseInstructor}); 72 | console.log(instructor); 73 | 74 | // { 75 | // "name": "sparky", 76 | // "coursename": "js basics ", 77 | // "price": "free" 78 | // } 79 | 80 | // [ 81 | // {}, 82 | // {}, 83 | // {} 84 | // ] -------------------------------------------------------------------------------- /Detailed Js/03_basics/01_functions.js: -------------------------------------------------------------------------------- 1 | 2 | // function sayMyName(){ 3 | // console.log("I"); 4 | // console.log("T"); 5 | // console.log("A"); 6 | // console.log("C"); 7 | // console.log("H"); 8 | // console.log("I"); 9 | // } 10 | 11 | // sayMyName(); 12 | 13 | // function addTwoNumbers(number1, number2){ 14 | // console.log(number1 + number2); 15 | // } 16 | 17 | // function addTwoNumbers(number1, number2){ 18 | 19 | // let result = number1 + number2 20 | // return result; 21 | // } 22 | 23 | // const result = addTwoNumbers(3, 5) 24 | 25 | // console.log("Result: ", result); 26 | 27 | 28 | // function loginUserMessage(username = "sam"){ 29 | // if(!username){ 30 | // console.log("PLease enter a username"); 31 | // return 32 | // } 33 | // return `${username} just logged in` 34 | // } 35 | 36 | // console.log(loginUserMessage("sparky")) 37 | // console.log(loginUserMessage()) 38 | 39 | 40 | // ... is rest/Spred operator 41 | 42 | // function calculateCartPrice(val1, val2, ...num1){ 43 | // return num1 44 | // } 45 | 46 | // console.log(calculateCartPrice(200, 400, 500, 2000,3000,4000)) 47 | 48 | // const user = { 49 | // username: "sparky", 50 | // age: 20 51 | // } 52 | 53 | // function handleObject(anyobject){ 54 | // console.log(`Username is ${anyobject.username} and Age is ${anyobject.age}`); 55 | // } 56 | 57 | // handleObject(user) 58 | // handleObject({ 59 | // username: "sam", 60 | // age: 50 61 | // }); 62 | 63 | // const myNewArray = [200, 400, 100, 600] 64 | 65 | // function returnSecondValue(getArray){ 66 | // return getArray[1] 67 | // } 68 | 69 | // console.log(returnSecondValue(myNewArray)); 70 | // console.log(returnSecondValue([200, 400, 500, 1000])); -------------------------------------------------------------------------------- /Detailed Js/03_basics/02_scopes.js: -------------------------------------------------------------------------------- 1 | // var c = 300 2 | // let a = 300 3 | // if (true) { 4 | // let a = 10 5 | // var c = 300 6 | // const b = 20 7 | // console.log("INNER: ", a); 8 | // console.log("INNER: ", b); 9 | // console.log("INNER: ", c); 10 | // } 11 | 12 | 13 | 14 | // console.log(a); 15 | // console.log(b); 16 | // console.log(c); 17 | 18 | // function one() { 19 | // const username = "Sparky" 20 | 21 | // function two() { 22 | // const website = "youtube" 23 | // console.log(username); 24 | // } 25 | // console.log(website); 26 | 27 | // two() 28 | 29 | // } 30 | 31 | // one() 32 | 33 | // if (true) { 34 | // var username = "Sparky" 35 | // if (username === "Sparky") { 36 | // var website = " youtube" 37 | // console.log(username + website); 38 | // } 39 | // console.log(website); 40 | // } 41 | // console.log(username); 42 | 43 | 44 | // if (true) { 45 | // let username = "Sparky" 46 | // if (username === "Sparky") { 47 | // const website = " youtube" 48 | // console.log(username + website); 49 | // } 50 | // console.log(website); 51 | // } 52 | // console.log(username); 53 | 54 | 55 | // ++++++++++++++++++ interesting ++++++++++++++++++ 56 | 57 | 58 | // console.log(addone(5)) 59 | 60 | // Normal Function 61 | 62 | // function addone(num){ 63 | // return num + 1 64 | // } 65 | 66 | 67 | // Expression function 68 | 69 | // addTwo(5) 70 | // const addTwo = function(num){ 71 | // return num + 2 72 | // } 73 | 74 | // Arrow function 75 | 76 | // addThree(5) 77 | // const addThree = (num) => { 78 | // return num + 3 79 | // } -------------------------------------------------------------------------------- /Detailed Js/03_basics/03_arrow.js: -------------------------------------------------------------------------------- 1 | // const user = { 2 | // username: "Sparky", 3 | // price: 999, 4 | 5 | // welcomeMessage: function() { 6 | // console.log(`${this.username} , welcome to website`); 7 | // console.log(this); 8 | // } 9 | 10 | // } 11 | 12 | // user.welcomeMessage() 13 | // user.username = "sam" 14 | // user.welcomeMessage() 15 | 16 | // console.log(this); 17 | 18 | // function chai(){ 19 | // let username = "Sparky" 20 | // console.log(this.username); 21 | // } 22 | 23 | // chai() 24 | 25 | // const chai = function () { 26 | // let username = "Sparky" 27 | // console.log(this.username); 28 | // } 29 | 30 | // const chai = () => { 31 | // let username = "Sparky" 32 | // console.log(this); 33 | // } 34 | 35 | 36 | // chai() 37 | 38 | // const addTwo = (num1, num2) => { 39 | // return num1 + num2 40 | // } 41 | 42 | // const addTwo = (num1, num2) => num1 + num2 43 | 44 | // const addTwo = (num1, num2) => ( num1 + num2 ) 45 | 46 | const addTwo = (num1, num2) => ({username: "Sparky"}) 47 | 48 | 49 | console.log(addTwo(3, 4)) 50 | 51 | 52 | const myArray = [2, 5, 3, 7, 8] 53 | 54 | myArray.forEach() -------------------------------------------------------------------------------- /Detailed Js/03_basics/04_iife.js: -------------------------------------------------------------------------------- 1 | // Immediately Invoked Function Expressions (IIFE) 2 | // Immediately Invoked Function Expressions (IIFE) use For remove Polution from Global scope 3 | 4 | 5 | (function chai(){ 6 | // named IIFE 7 | console.log(`DB CONNECTED`); 8 | })(); 9 | 10 | // ( (name) => { 11 | // console.log(`DB CONNECTED TWO ${name}`); 12 | // } )('hitesh') 13 | 14 | 15 | ( (fun1)=> { 16 | console.log(`DB CONNECTED THREE`); 17 | }) 18 | (); -------------------------------------------------------------------------------- /Detailed Js/04_control_flow/one.js: -------------------------------------------------------------------------------- 1 | // if 2 | // const isUserloggedIn = true 3 | // const temperature = 41 4 | 5 | // if ( temperature <= 49 ){ 6 | // console.log("less than 50"); 7 | // } else { 8 | // console.log("temperature is greater than 50"); 9 | // } 10 | 11 | // console.log("Execute"); 12 | // <, >, <=, >=, ==, !=, ===, !== 13 | 14 | // const score = 200 15 | 16 | // if (score > 100) { 17 | // let power = "fly" 18 | // console.log(`User power: ${power}`); 19 | // } 20 | 21 | // console.log(`User power: ${power}`); 22 | 23 | 24 | // const balance = 1000 25 | 26 | // if (balance > 500) console.log("test"),console.log("test2"); 27 | 28 | // if (balance < 500) { 29 | // console.log("less than 500"); 30 | // } else if (balance < 750) { 31 | // console.log("less than 750"); 32 | 33 | // } else if (balance < 900) { 34 | // console.log("less than 750"); 35 | 36 | // } else { 37 | // console.log("less than 1200"); 38 | // } 39 | 40 | // const userLoggedIn = true 41 | // const debitCard = true 42 | // const loggedInFromGoogle = false 43 | // const loggedInFromEmail = true 44 | 45 | // if (userLoggedIn && debitCard && 2==3) { 46 | // console.log("Allow to buy course"); 47 | // } 48 | 49 | // if (loggedInFromGoogle || loggedInFromEmail) { 50 | // console.log("User logged in"); 51 | // } -------------------------------------------------------------------------------- /Detailed Js/04_control_flow/switch.js: -------------------------------------------------------------------------------- 1 | // switch (key) { 2 | // case value: 3 | 4 | // break; 5 | 6 | // default: 7 | // break; 8 | // } 9 | 10 | const month = "march" 11 | 12 | switch (month) { 13 | case "jan": 14 | console.log("January"); 15 | break; 16 | case "feb": 17 | console.log("feb"); 18 | break; 19 | case "march": 20 | console.log("march"); 21 | break; 22 | case "april": 23 | console.log("april"); 24 | break; 25 | 26 | default: 27 | console.log("default case match"); 28 | break; 29 | } -------------------------------------------------------------------------------- /Detailed Js/04_control_flow/truthy.js: -------------------------------------------------------------------------------- 1 | // const userEmail = ["user@gmail.com"] 2 | // const userEmail = {} 3 | 4 | // if (userEmail) { 5 | // console.log("Got user email"); 6 | // } else { 7 | // console.log("Don't have user email"); 8 | // } 9 | 10 | // console.log(typeof userEmail); 11 | 12 | 13 | // falsy values 14 | 15 | // false, 0, -0, BigInt 0n, "", null, undefined, NaN 16 | 17 | //truthy values 18 | // "0", 'false', " ", [], {}, function(){} 19 | 20 | // if (userEmail.length === 0) { 21 | // console.log("Array is empty"); 22 | // } 23 | 24 | // const emptyObj = {} 25 | 26 | // if (Object.keys(emptyObj).length === 0) { 27 | // console.log("Object is empty"); 28 | // } 29 | 30 | // Nullish Coalescing Operator (??): null undefined 31 | 32 | // let val1; 33 | // val1 = 5 ?? 10 34 | // val1 = null ?? 10 35 | // val1 = undefined ?? 15 36 | // val1 = null ?? 10 ?? 20 37 | 38 | 39 | 40 | // console.log(val1); 41 | 42 | // Terniary Operator 43 | 44 | // condition ? true : false 45 | 46 | const iceTeaPrice = 100 47 | iceTeaPrice <= 80 ? console.log("less than 80") : console.log("more than 80") -------------------------------------------------------------------------------- /Detailed Js/05_iterations/five.js: -------------------------------------------------------------------------------- 1 | const coding = ["js", "ruby", "java", "python", "cpp"] 2 | 3 | // coding.forEach( function (val){ 4 | // console.log(val); 5 | // }); 6 | 7 | // coding.forEach( (item) => { 8 | // console.log(item); 9 | // }); 10 | 11 | // function printMe(item){ 12 | // console.log(item); 13 | // } 14 | 15 | // coding.forEach(printMe) 16 | 17 | // coding.forEach( (item, index, arr)=> { 18 | // console.log(item, index, arr); 19 | // }); 20 | 21 | const myCoding = [ 22 | { 23 | languageName: "javascript", 24 | languageFileName: "js" 25 | }, 26 | { 27 | languageName: "java", 28 | languageFileName: "java" 29 | }, 30 | { 31 | languageName: "python", 32 | languageFileName: "py" 33 | }, 34 | ] 35 | 36 | myCoding.forEach((item) => { 37 | console.log(item.languageName,' ',item.languageFileName); 38 | }) -------------------------------------------------------------------------------- /Detailed Js/05_iterations/four.js: -------------------------------------------------------------------------------- 1 | const myObject = { 2 | js: 'javascript', 3 | cpp: 'C++', 4 | rb: "ruby", 5 | swift: "swift by apple" 6 | } 7 | 8 | // for (const key in myObject) { 9 | // console.log(`${key} shortcut is for ${myObject[key]}`); 10 | // } 11 | 12 | // const programming = ["js", "rb", "py", "java", "cpp"] 13 | 14 | // for (const key in programming) { 15 | // console.log(programming[key]); 16 | // } 17 | 18 | // const map = new Map() 19 | // map.set('IN', "India") 20 | // map.set('USA', "United States of America") 21 | // map.set('Fr', "France") 22 | // map.set('IN', "India") 23 | 24 | // for (const key in map) { 25 | // console.log(key); 26 | // } -------------------------------------------------------------------------------- /Detailed Js/05_iterations/nine.js: -------------------------------------------------------------------------------- 1 | const myNums = [10, 20, 30]; 2 | 3 | // const myTotal = myNums.reduce(function (acc, currval) { 4 | // console.log(`acc: ${acc} and currval: ${currval}`); 5 | // return acc + currval 6 | // }, 0); 7 | 8 | // const myTotal = myNums.reduce( (acc, curr) => acc+curr, 0) 9 | 10 | // console.log(myTotal); 11 | 12 | const shoppingCart = [ 13 | { 14 | itemName: "js course", 15 | price: 1000 16 | }, 17 | { 18 | itemName: "py course", 19 | price: 999 20 | }, 21 | { 22 | itemName: "mobile dev course", 23 | price: 5000 24 | }, 25 | { 26 | itemName: "data science course", 27 | price: 13000 28 | }, 29 | ] 30 | 31 | const priceToPay = shoppingCart.reduce((acc, item) => acc + item.price , 0) 32 | 33 | console.log(priceToPay); -------------------------------------------------------------------------------- /Detailed Js/05_iterations/one.js: -------------------------------------------------------------------------------- 1 | // for 2 | 3 | // for (let i = 0; i <= 10; i++) { 4 | // const element = i; 5 | // if (element == 5) { 6 | // console.log("5 is best number"); 7 | // } 8 | // console.log(element); 9 | 10 | // } 11 | 12 | // console.log(element); 13 | 14 | // for (let i = 1; i <= 10; i++) { 15 | // console.log(`Outer loop value: ${i}`); 16 | // for (let j = 1; j <= 10; j++) { 17 | // console.log(`Inner loop value ${j} and inner loop ${i}`); 18 | // console.log(i + '*' + j + ' = ' + i*j ); 19 | // } 20 | // } 21 | // let myArray = ["flash", "batman", "superman"] 22 | // console.log(myArray.length); 23 | // for (let index = 0; index < myArray.length; index++) { 24 | // const element = myArray[index]; 25 | // const element = index; 26 | // console.log(element); 27 | // } 28 | 29 | 30 | // break and continue 31 | 32 | // for (let index = 1; index <= 20; index++) { 33 | // if (index == 5) { 34 | // console.log(`Detected 5`); 35 | // break 36 | // } 37 | // console.log(`Value of i is ${index}`); 38 | 39 | // } 40 | 41 | for (let index = 1; index <= 20; index++) { 42 | if (index == 5) { 43 | console.log(`Detected 5`); 44 | continue 45 | } 46 | console.log(`Value of i is ${index}`); 47 | 48 | } -------------------------------------------------------------------------------- /Detailed Js/05_iterations/seven.js: -------------------------------------------------------------------------------- 1 | const myNumers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 2 | 3 | // const newNums = myNumers.map( (num) => { return num + 10}) 4 | 5 | const newNums = myNumers 6 | .map((num) => num * 10) 7 | .map((num) => num + 1) 8 | .filter((num) => num >= 40) 9 | 10 | console.log(newNums); -------------------------------------------------------------------------------- /Detailed Js/05_iterations/six.js: -------------------------------------------------------------------------------- 1 | // const coding = ["js", "ruby", "java", "python", "cpp"] 2 | 3 | 4 | // const values = coding.forEach( (item) => { 5 | // console.log(item); 6 | // // return item 7 | // } ) 8 | 9 | // console.log(values); 10 | 11 | const myNums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 12 | 13 | // const newNums = myNums.filter( (num) => { 14 | // return num > 4 15 | // }) 16 | 17 | // const newNums = [] 18 | 19 | // myNums.forEach((num) => { 20 | // if (num > 4) { 21 | // newNums.push(num) 22 | // } 23 | // }) 24 | 25 | // console.log(myNums); 26 | // console.log(newNums); 27 | 28 | 29 | const books = [ 30 | { title: 'Book One', genre: 'Fiction', publish: 1981, edition: 2004 }, 31 | { title: 'Book Two', genre: 'Non-Fiction', publish: 1992, edition: 2008 }, 32 | { title: 'Book Three', genre: 'History', publish: 1999, edition: 2007 }, 33 | { title: 'Book Four', genre: 'Non-Fiction', publish: 1989, edition: 2010 }, 34 | { title: 'Book Five', genre: 'Science', publish: 2009, edition: 2014 }, 35 | { title: 'Book Six', genre: 'Fiction', publish: 1987, edition: 2010 }, 36 | { title: 'Book Seven', genre: 'History', publish: 1986, edition: 1996 }, 37 | { title: 'Book Eight', genre: 'Science', publish: 2011, edition: 2016 }, 38 | { title: 'Book Nine', genre: 'Non-Fiction', publish: 1981, edition: 1989 }, 39 | ]; 40 | 41 | // let userBooks = books.filter( (bk) => bk.genre === 'History') 42 | 43 | userBooks = books.filter((bk) => { 44 | return bk.publish >= 1995 && bk.genre === "History" 45 | }) 46 | console.log(userBooks); -------------------------------------------------------------------------------- /Detailed Js/05_iterations/three.js: -------------------------------------------------------------------------------- 1 | // for of 2 | 3 | // ["", "", ""] 4 | // [{}, {}, {}] 5 | 6 | // const arr = [1, 2, 3, 4, 5] 7 | 8 | // for (const num of arr) { 9 | // console.log(num); 10 | // } 11 | 12 | // const greetings = "Hello world!" 13 | // for (const greet of greetings) { 14 | // console.log(`Each char is ${greet}`) 15 | // } 16 | 17 | // Maps 18 | 19 | // const map = new Map() 20 | // map.set('IN', "India") 21 | // map.set('USA', "United States of America") 22 | // map.set('Fr', "France") 23 | // map.set('IN', "India") 24 | 25 | 26 | // console.log(map); 27 | 28 | // for (const [key, value] of map) { 29 | // console.log(key, ':-', value); 30 | // } 31 | 32 | const myObject = { 33 | game1: 'NFS', 34 | game2: 'Spiderman' 35 | } 36 | 37 | // for (const [key, value] of myObject) { 38 | // console.log(key, ':-', value); 39 | // console.log(i, ':-', myObject[i]); 40 | // } -------------------------------------------------------------------------------- /Detailed Js/05_iterations/two.js: -------------------------------------------------------------------------------- 1 | // let index = 0 2 | // while (index <= 10) { 3 | // console.log(`Value of index is ${index}`); 4 | // index = index + 2 5 | // } 6 | 7 | // let myArray = ['flash', "batman", "superman"] 8 | 9 | // let arr = 0 10 | // while (arr < myArray.length) { 11 | // console.log(`Value is ${myArray[arr]}`); 12 | // arr = arr + 1 13 | // OR 14 | // arr++ 15 | // } 16 | 17 | // let score = 11 18 | 19 | // do { 20 | // console.log(`Score is ${score}`); 21 | // score++ 22 | // } while (score <= 10); -------------------------------------------------------------------------------- /Detailed Js/06_dom/four.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Chai aur code | DOM 8 | 9 | 10 |
    11 |
  • Javascript
  • 12 |
13 | 14 | 48 | -------------------------------------------------------------------------------- /Detailed Js/06_dom/one.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | DOM learning 7 | 13 | 14 | 15 |
16 |

DOM learning on Chai aur code test text

17 |

Lorem ipsum dolor sit.

18 |

Lorem ipsum dolor sit.

19 |

Lorem ipsum dolor sit.

20 |

Lorem ipsum dolor sit amet.

21 | 22 | 23 |
    24 |
  • one
  • 25 |
  • two
  • 26 |
  • three
  • 27 |
  • four
  • 28 |
29 |
30 | 31 | -------------------------------------------------------------------------------- /Detailed Js/06_dom/three.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Chai aur code 8 | 9 | 10 | 11 | 12 | 26 | -------------------------------------------------------------------------------- /Detailed Js/06_dom/two.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | DOM | Chai aur code 8 | 9 | 10 |
11 | 12 |
Monday
13 |
Tuesday
14 |
Wednesday
15 |
Thursday
16 |
17 | 18 | 38 | -------------------------------------------------------------------------------- /Detailed Js/07_projects/projectsset1.md: -------------------------------------------------------------------------------- 1 | # Projects related to DOM 2 | 3 | ## project link 4 | [Click here](https://stackblitz.com/edit/dom-project-chaiaurcode?file=index.html) 5 | 6 | # Solution code 7 | 8 | ## project 1 9 | 10 | ```javascript 11 | console.log("hitesh") 12 | const buttons = document.querySelectorAll('.button'); 13 | const body = document.querySelector('body'); 14 | 15 | buttons.forEach(function (button) { 16 | console.log(button); 17 | button.addEventListener('click', function (e) { 18 | console.log(e); 19 | console.log(e.target); 20 | if (e.target.id === 'grey') { 21 | body.style.backgroundColor = e.target.id; 22 | } 23 | if (e.target.id === 'white') { 24 | body.style.backgroundColor = e.target.id; 25 | } 26 | if (e.target.id === 'blue') { 27 | body.style.backgroundColor = e.target.id; 28 | } 29 | if (e.target.id === 'yellow') { 30 | body.style.backgroundColor = e.target.id; 31 | } 32 | 33 | }); 34 | }); 35 | 36 | 37 | ``` 38 | 39 | ## project 2 solution 40 | 41 | ```javascript 42 | const form = document.querySelector('form'); 43 | // this usecase will give you empty 44 | // const height = parseInt(document.querySelector('#height').value) 45 | 46 | form.addEventListener('submit', function (e) { 47 | e.preventDefault(); 48 | 49 | const height = parseInt(document.querySelector('#height').value); 50 | const weight = parseInt(document.querySelector('#weight').value); 51 | const results = document.querySelector('#results'); 52 | 53 | if (height === '' || height < 0 || isNaN(height)) { 54 | results.innerHTML = `Please give a valid height ${height}`; 55 | } else if (weight === '' || weight < 0 || isNaN(weight)) { 56 | results.innerHTML = `Please give a valid weight ${weight}`; 57 | } else { 58 | const bmi = (weight / ((height * height) / 10000)).toFixed(2); 59 | //show the result 60 | results.innerHTML = `${bmi}`; 61 | } 62 | }); 63 | 64 | 65 | ``` 66 | 67 | ## project 3 solution code 68 | 69 | ```javascript 70 | const clock = document.getElementById('clock'); 71 | // const clock = document.querySelector('#clock') 72 | 73 | setInterval(function () { 74 | let date = new Date(); 75 | // console.log(date.toLocaleTimeString()); 76 | clock.innerHTML = date.toLocaleTimeString(); 77 | }, 1000); 78 | 79 | 80 | ``` 81 | 82 | ## project 4 solution 83 | 84 | 85 | ```javascript 86 | 87 | let randomNumber = parseInt(Math.random() * 100 + 1); 88 | 89 | const submit = document.querySelector('#subt'); 90 | const userInput = document.querySelector('#guessField'); 91 | const guessSlot = document.querySelector('.guesses'); 92 | const remaining = document.querySelector('.lastResult'); 93 | const lowOrHi = document.querySelector('.lowOrHi'); 94 | const startOver = document.querySelector('.resultParas'); 95 | 96 | const p = document.createElement('p'); 97 | 98 | let prevGuess = []; 99 | let numGuess = 1; 100 | 101 | let playGame = true; 102 | 103 | if (playGame) { 104 | submit.addEventListener('click', function (e) { 105 | e.preventDefault(); 106 | const guess = parseInt(userInput.value); 107 | console.log(guess); 108 | validateGuess(guess); 109 | }); 110 | } 111 | 112 | function validateGuess(guess) { 113 | if (isNaN(guess)) { 114 | alert('PLease enter a valid number'); 115 | } else if (guess < 1) { 116 | alert('PLease enter a number more than 1'); 117 | } else if (guess > 100) { 118 | alert('PLease enter a number less than 100'); 119 | } else { 120 | prevGuess.push(guess); 121 | if (numGuess === 11) { 122 | displayGuess(guess); 123 | displayMessage(`Game Over. Random number was ${randomNumber}`); 124 | endGame(); 125 | } else { 126 | displayGuess(guess); 127 | checkGuess(guess); 128 | } 129 | } 130 | } 131 | 132 | function checkGuess(guess) { 133 | if (guess === randomNumber) { 134 | displayMessage(`You guessed it right`); 135 | endGame(); 136 | } else if (guess < randomNumber) { 137 | displayMessage(`Number is TOOO low`); 138 | } else if (guess > randomNumber) { 139 | displayMessage(`Number is TOOO High`); 140 | } 141 | } 142 | 143 | function displayGuess(guess) { 144 | userInput.value = ''; 145 | guessSlot.innerHTML += `${guess}, `; 146 | numGuess++; 147 | remaining.innerHTML = `${11 - numGuess} `; 148 | } 149 | 150 | function displayMessage(message) { 151 | lowOrHi.innerHTML = `

${message}

`; 152 | } 153 | 154 | function endGame() { 155 | userInput.value = ''; 156 | userInput.setAttribute('disabled', ''); 157 | p.classList.add('button'); 158 | p.innerHTML = `

Start new Game

`; 159 | startOver.appendChild(p); 160 | playGame = false; 161 | newGame(); 162 | } 163 | 164 | function newGame() { 165 | const newGameButton = document.querySelector('#newGame'); 166 | newGameButton.addEventListener('click', function (e) { 167 | randomNumber = parseInt(Math.random() * 100 + 1); 168 | prevGuess = []; 169 | numGuess = 1; 170 | guessSlot.innerHTML = ''; 171 | remaining.innerHTML = `${11 - numGuess} `; 172 | userInput.removeAttribute('disabled'); 173 | startOver.removeChild(p); 174 | 175 | playGame = true; 176 | }); 177 | } 178 | 179 | 180 | ``` 181 | 182 | 183 | # Project 5 solution 184 | 185 | ```javascript 186 | const insert = document.getElementById('insert'); 187 | 188 | window.addEventListener('keydown', (e) => { 189 | insert.innerHTML = ` 190 |
191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 |
KeyKeycodeCode
${e.key === ' ' ? 'Space' : e.key}${e.keyCode}${e.code}
204 |
205 | `; 206 | }); 207 | 208 | 209 | ``` 210 | 211 | # Project 6 Solution 212 | 213 | ```javascript 214 | //generate a random color 215 | 216 | const randomColor = function () { 217 | const hex = '0123456789ABCDEF'; 218 | let color = '#'; 219 | for (let i = 0; i < 6; i++) { 220 | color += hex[Math.floor(Math.random() * 16)]; 221 | } 222 | return color; 223 | }; 224 | 225 | let intervalId; 226 | const startChangingColor = function () { 227 | if (!intervalId) { 228 | intervalId = setInterval(changeBgColor, 1000); 229 | } 230 | 231 | function changeBgColor() { 232 | document.body.style.backgroundColor = randomColor(); 233 | } 234 | }; 235 | const stopChangingColor = function () { 236 | clearInterval(intervalId); 237 | intervalId = null; 238 | }; 239 | 240 | document.querySelector('#start').addEventListener('click', startChangingColor); 241 | 242 | document.querySelector('#stop').addEventListener('click', stopChangingColor); 243 | 244 | 245 | ``` -------------------------------------------------------------------------------- /Detailed Js/08_events/eventbasics.js: -------------------------------------------------------------------------------- 1 | console.log("Getting started with event"); -------------------------------------------------------------------------------- /Detailed Js/08_events/one.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | htnml Events 7 | 8 | 9 |

Amazing image

10 |
11 |
    12 |
  • photoshop
  • 13 |
  • 14 |
  • 15 |
  • 16 |
  • 17 |
  • Google
  • 18 |
19 |
20 | 21 | 63 | -------------------------------------------------------------------------------- /Detailed Js/08_events/three.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 |

Chai aur Javascript

10 | 11 | 12 | 13 | 22 | -------------------------------------------------------------------------------- /Detailed Js/08_events/two.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 |

Chai aur code

10 | 11 | 12 | 27 | -------------------------------------------------------------------------------- /Detailed Js/09_advance_one/ApiRequest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 0 UNSENT Client has been created. open() not called yet. 10 | 1 OPENED open() has been called. 11 | 2 HEADERS_RECEIVED send() has been called, and headers and status are available. 12 | 3 LOADING Downloading; responseText holds partial data. 13 | 4 DONE The operation is complete. 14 | 15 | 29 | -------------------------------------------------------------------------------- /Detailed Js/09_advance_one/promise.js: -------------------------------------------------------------------------------- 1 | console.log("promises"); -------------------------------------------------------------------------------- /Detailed Js/09_advance_one/promises.js: -------------------------------------------------------------------------------- 1 | const promiseOne = new Promise(function(resolve, reject){ 2 | //Do an async task 3 | // DB calls, cryptography, network 4 | setTimeout(function(){ 5 | console.log('Async task is compelete'); 6 | resolve() 7 | }, 1000) 8 | }) 9 | 10 | promiseOne.then(function(){ 11 | console.log("Promise consumed"); 12 | }) 13 | 14 | new Promise(function(resolve, reject){ 15 | setTimeout(function(){ 16 | console.log("Async task 2"); 17 | resolve() 18 | }, 1000) 19 | 20 | }).then(function(){ 21 | console.log("Async 2 resolved"); 22 | }) 23 | 24 | const promiseThree = new Promise(function(resolve, reject){ 25 | setTimeout(function(){ 26 | resolve({username: "Chai", email: "chai@example.com"}) 27 | }, 1000) 28 | }) 29 | 30 | promiseThree.then(function(user){ 31 | console.log(user); 32 | }) 33 | 34 | const promiseFour = new Promise(function(resolve, reject){ 35 | setTimeout(function(){ 36 | let error = true 37 | if (!error) { 38 | resolve({username: "hitesh", password: "123"}) 39 | } else { 40 | reject('ERROR: Something went wrong') 41 | } 42 | }, 1000) 43 | }) 44 | 45 | promiseFour 46 | .then((user) => { 47 | console.log(user); 48 | return user.username 49 | }).then((username) => { 50 | console.log(username); 51 | }).catch(function(error){ 52 | console.log(error); 53 | }).finally(() => console.log("The promise is either resolved or rejected")) 54 | 55 | 56 | 57 | const promiseFive = new Promise(function(resolve, reject){ 58 | setTimeout(function(){ 59 | let error = true 60 | if (!error) { 61 | resolve({username: "javascript", password: "123"}) 62 | } else { 63 | reject('ERROR: JS went wrong') 64 | } 65 | }, 1000) 66 | }); 67 | 68 | async function consumePromiseFive(){ 69 | try { 70 | const response = await promiseFive 71 | console.log(response); 72 | } catch (error) { 73 | console.log(error); 74 | } 75 | } 76 | 77 | consumePromiseFive() 78 | 79 | // async function getAllUsers(){ 80 | // try { 81 | // const response = await fetch('https://jsonplaceholder.typicode.com/users') 82 | 83 | // const data = await response.json() 84 | // console.log(data); 85 | // } catch (error) { 86 | // console.log("E: ", error); 87 | // } 88 | // } 89 | 90 | //getAllUsers() 91 | 92 | fetch('https://api.github.com/users/hiteshchoudhary') 93 | .then((response) => { 94 | return response.json() 95 | }) 96 | .then((data) => { 97 | console.log(data); 98 | }) 99 | .catch((error) => console.log(error)) 100 | 101 | // promise.all 102 | // yes this is also available, kuch reading aap b kro. -------------------------------------------------------------------------------- /Detailed Js/10_classes_and_oop/Object.js: -------------------------------------------------------------------------------- 1 | function multipleBy5(num){ 2 | 3 | return num*5 4 | } 5 | 6 | multipleBy5.power = 2 7 | 8 | console.log(multipleBy5(5)); 9 | console.log(multipleBy5.power); 10 | console.log(multipleBy5.prototype); 11 | 12 | function createUser(username, score){ 13 | this.username = username 14 | this.score = score 15 | } 16 | 17 | createUser.prototype.increment = function(){ 18 | this.score++ 19 | } 20 | createUser.prototype.printMe = function(){ 21 | console.log(`price is ${this.score}`); 22 | } 23 | 24 | const chai = new createUser("chai", 25) 25 | const tea = createUser("tea", 250) 26 | 27 | chai.printMe() 28 | 29 | 30 | /* 31 | 32 | Here's what happens behind the scenes when the new keyword is used: 33 | 34 | A new object is created: The new keyword initiates the creation of a new JavaScript object. 35 | 36 | A prototype is linked: The newly created object gets linked to the prototype property of the constructor function. This means that it has access to properties and methods defined on the constructor's prototype. 37 | 38 | The constructor is called: The constructor function is called with the specified arguments and this is bound to the newly created object. If no explicit return value is specified from the constructor, JavaScript assumes this, the newly created object, to be the intended return value. 39 | 40 | The new object is returned: After the constructor function has been called, if it doesn't return a non-primitive value (object, array, function, etc.), the newly created object is returned. 41 | 42 | */ -------------------------------------------------------------------------------- /Detailed Js/10_classes_and_oop/Prototype.js: -------------------------------------------------------------------------------- 1 | // let myName = "hitesh " 2 | // let mychannel = "chai " 3 | 4 | // console.log(myName.trueLength); 5 | 6 | 7 | let myHeros = ["thor", "spiderman"] 8 | 9 | 10 | let heroPower = { 11 | thor: "hammer", 12 | spiderman: "sling", 13 | 14 | getSpiderPower: function(){ 15 | console.log(`Spidy power is ${this.spiderman}`); 16 | } 17 | } 18 | 19 | Object.prototype.hitesh = function(){ 20 | console.log(`hitesh is present in all objects`); 21 | } 22 | 23 | Array.prototype.heyHitesh = function(){ 24 | console.log(`Hitesh says hello`); 25 | } 26 | 27 | // heroPower.hitesh() 28 | // myHeros.hitesh() 29 | // myHeros.heyHitesh() 30 | // heroPower.heyHitesh() 31 | 32 | // inheritance 33 | 34 | const User = { 35 | name: "chai", 36 | email: "chai@google.com" 37 | } 38 | 39 | const Teacher = { 40 | makeVideo: true 41 | } 42 | 43 | const TeachingSupport = { 44 | isAvailable: false 45 | } 46 | 47 | const TASupport = { 48 | makeAssignment: 'JS assignment', 49 | fullTime: true, 50 | __proto__: TeachingSupport 51 | } 52 | 53 | Teacher.__proto__ = User 54 | 55 | // modern syntax 56 | Object.setPrototypeOf(TeachingSupport, Teacher) 57 | 58 | let anotherUsername = "ChaiAurCode " 59 | 60 | String.prototype.trueLength = function(){ 61 | console.log(`${this}`); 62 | console.log(`True length is: ${this.trim().length}`); 63 | } 64 | 65 | anotherUsername.trueLength() 66 | "hitesh".trueLength() 67 | "iceTea".trueLength() -------------------------------------------------------------------------------- /Detailed Js/10_classes_and_oop/bind.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | React 7 | 8 | 9 | 10 | 11 | 31 | -------------------------------------------------------------------------------- /Detailed Js/10_classes_and_oop/call.js: -------------------------------------------------------------------------------- 1 | function SetUsername(username){ 2 | //complex DB calls 3 | this.username = username 4 | console.log("called"); 5 | } 6 | 7 | function createUser(username, email, password){ 8 | SetUsername.call(this, username) 9 | 10 | this.email = email 11 | this.password = password 12 | } 13 | 14 | const chai = new createUser("chai", "chai@fb.com", "123") 15 | console.log(chai); -------------------------------------------------------------------------------- /Detailed Js/10_classes_and_oop/getter_setter.js: -------------------------------------------------------------------------------- 1 | class User { 2 | constructor(email, password){ 3 | this.email = email; 4 | this.password = password 5 | } 6 | 7 | get email(){ 8 | return this._email.toUpperCase() 9 | } 10 | set email(value){ 11 | this._email = value 12 | } 13 | 14 | get password(){ 15 | return `${this._password}hitesh` 16 | } 17 | 18 | set password(value){ 19 | this._password = value 20 | } 21 | } 22 | 23 | const hitesh = new User("h@hitesh.ai", "abc") 24 | console.log(hitesh.email); -------------------------------------------------------------------------------- /Detailed Js/10_classes_and_oop/inheritance.js: -------------------------------------------------------------------------------- 1 | class User { 2 | constructor(username){ 3 | this.username = username 4 | } 5 | 6 | logMe(){ 7 | console.log(`USERNAME is ${this.username}`); 8 | } 9 | } 10 | 11 | class Teacher extends User{ 12 | constructor(username, email, password){ 13 | super(username) 14 | this.email = email 15 | this.password = password 16 | } 17 | 18 | addCourse(){ 19 | console.log(`A new course was added by ${this.username}`); 20 | } 21 | } 22 | 23 | const chai = new Teacher("chai", "chai@teacher.com", "123") 24 | 25 | chai.logMe() 26 | const masalaChai = new User("masalaChai") 27 | 28 | masalaChai.logMe() 29 | 30 | console.log(chai instanceof User); -------------------------------------------------------------------------------- /Detailed Js/10_classes_and_oop/mathpi.js: -------------------------------------------------------------------------------- 1 | const descripter = Object.getOwnPropertyDescriptor(Math, "PI") 2 | 3 | // console.log(descripter); 4 | 5 | // console.log(Math.PI); 6 | // Math.PI = 5 7 | // console.log(Math.PI); 8 | 9 | const chai = { 10 | name: 'ginger chai', 11 | price: 250, 12 | isAvailable: true, 13 | 14 | orderChai: function(){ 15 | console.log("chai nhi bni"); 16 | } 17 | } 18 | 19 | console.log(Object.getOwnPropertyDescriptor(chai, "name")); 20 | 21 | Object.defineProperty(chai, 'name', { 22 | //writable: false, 23 | enumerable: true, 24 | 25 | }) 26 | 27 | console.log(Object.getOwnPropertyDescriptor(chai, "name")); 28 | 29 | for (let [key, value] of Object.entries(chai)) { 30 | if (typeof value !== 'function') { 31 | 32 | console.log(`${key} : ${value}`); 33 | } 34 | } -------------------------------------------------------------------------------- /Detailed Js/10_classes_and_oop/myClasses.js: -------------------------------------------------------------------------------- 1 | // ES6 2 | 3 | class User { 4 | constructor(username, email, password){ 5 | this.username = username; 6 | this.email = email; 7 | this.password = password 8 | } 9 | 10 | encryptPassword(){ 11 | return `${this.password}abc` 12 | } 13 | changeUsername(){ 14 | return `${this.username.toUpperCase()}` 15 | } 16 | 17 | } 18 | 19 | const chai = new User("chai", "chai@gmail.com", "123") 20 | 21 | console.log(chai.encryptPassword()); 22 | console.log(chai.changeUsername()); 23 | 24 | // behind the scene 25 | 26 | function User(username, email, password){ 27 | this.username = username; 28 | this.email = email; 29 | this.password = password 30 | } 31 | 32 | User.prototype.encryptPassword = function(){ 33 | return `${this.password}abc` 34 | } 35 | User.prototype.changeUsername = function(){ 36 | return `${this.username.toUpperCase()}` 37 | } 38 | 39 | 40 | const tea = new User("tea", "tea@gmail.com", "123") 41 | 42 | console.log(tea.encryptPassword()); 43 | console.log(tea.changeUsername()); -------------------------------------------------------------------------------- /Detailed Js/10_classes_and_oop/notes.md: -------------------------------------------------------------------------------- 1 | # javascript and classes 2 | 3 | ## OOP 4 | 5 | ## Object 6 | - collection of properties and methods 7 | - toLowerCase 8 | 9 | ## why use OOP 10 | 11 | ## parts of OOP 12 | Object literal 13 | 14 | - Constructor function 15 | - Prototypes 16 | - Classes 17 | - Instances (new, this) 18 | 19 | 20 | ## 4 pillars 21 | Abstraction 22 | Encapsulation 23 | Inheritance 24 | Polymorphism -------------------------------------------------------------------------------- /Detailed Js/10_classes_and_oop/object_get_set.js: -------------------------------------------------------------------------------- 1 | const User = { 2 | _email: 'h@hc.com', 3 | _password: "abc", 4 | 5 | 6 | get email(){ 7 | return this._email.toUpperCase() 8 | }, 9 | 10 | set email(value){ 11 | this._email = value 12 | } 13 | } 14 | 15 | const tea = Object.create(User) 16 | console.log(tea.email); -------------------------------------------------------------------------------- /Detailed Js/10_classes_and_oop/oop.js: -------------------------------------------------------------------------------- 1 | const user = { 2 | username: "hitesh", 3 | loginCount: 8, 4 | signedIn: true, 5 | 6 | getUserDetails: function(){ 7 | //console.log("Got user details from database"); 8 | // console.log(`Username: ${this.username}`); 9 | console.log(this); 10 | } 11 | 12 | } 13 | 14 | 15 | 16 | //console.log(user.username) 17 | //console.log(user.getUserDetails()); 18 | // console.log(this); 19 | 20 | 21 | function User(username, loginCount, isLoggedIn){ 22 | this.username = username; 23 | this.loginCount = loginCount; 24 | this.isLoggedIn = isLoggedIn 25 | 26 | this.greeting = function(){ 27 | console.log(`Welcome ${this.username}`); 28 | 29 | } 30 | 31 | return this 32 | } 33 | 34 | const userOne = new User("hitesh", 12, true) 35 | const userTwo = new User("ChaiAurCode", 11, false) 36 | console.log(userOne.constructor); 37 | //console.log(userTwo); -------------------------------------------------------------------------------- /Detailed Js/10_classes_and_oop/properties_get_set.js: -------------------------------------------------------------------------------- 1 | function User(email, password){ 2 | this._email = email; 3 | this._password = password 4 | 5 | Object.defineProperty(this, 'email', { 6 | get: function(){ 7 | return this._email.toUpperCase() 8 | }, 9 | set: function(value){ 10 | this._email = value 11 | } 12 | }) 13 | Object.defineProperty(this, 'password', { 14 | get: function(){ 15 | return this._password.toUpperCase() 16 | }, 17 | set: function(value){ 18 | this._password = value 19 | } 20 | }) 21 | 22 | } 23 | 24 | const chai = new User("chai@chai.com", "chai") 25 | 26 | console.log(chai.email); -------------------------------------------------------------------------------- /Detailed Js/10_classes_and_oop/staticprop.js: -------------------------------------------------------------------------------- 1 | class User { 2 | constructor(username){ 3 | this.username = username 4 | } 5 | 6 | logMe(){ 7 | console.log(`Username: ${this.username}`); 8 | } 9 | 10 | static createId(){ 11 | return `123` 12 | } 13 | } 14 | 15 | const hitesh = new User("hitesh") 16 | // console.log(hitesh.createId()) 17 | 18 | class Teacher extends User { 19 | constructor(username, email){ 20 | super(username) 21 | this.email = email 22 | } 23 | } 24 | 25 | const iphone = new Teacher("iphone", "i@phone.com") 26 | console.log(iphone.createId()); -------------------------------------------------------------------------------- /Detailed Js/11_fun_with_js/closure.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Closure aur chai 7 | 8 | 9 | 10 | 11 | 12 | 13 | 54 | 74 | -------------------------------------------------------------------------------- /Lecture/Object in Js/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Object In js 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Lecture/Object in Js/loop.js: -------------------------------------------------------------------------------- 1 | let student = { 2 | name: "Scout", 3 | age: 20, 4 | gender: "male", 5 | hobbies: ["reading", "gaming", "travelling"], 6 | address: { 7 | city: "Surat", 8 | state: "Gujrat", 9 | phone: 90909090 10 | } 11 | } 12 | 13 | // console.log(student); 14 | 15 | // ============ For In loop ==============(work on array/Object)========== 16 | 17 | // for (let i in student) { 18 | // if (i == "hobbies") { 19 | // student.hobbies.map((val)=>{ 20 | // console.log(`hobbies => ${val}`); 21 | // }); 22 | // }else{ 23 | // console.log(`${i} => ${student[i]}`); 24 | // } 25 | // } 26 | 27 | // ============ For Of loop ==============(Only work on array)========== 28 | 29 | // let marks = [60,80,90,85,30] ; 30 | 31 | // for (let i of marks){ 32 | // console.log(i); 33 | // } 34 | 35 | // console.log(student.hobbies); 36 | // console.log(student["address"]); 37 | console.log(Object.entries(student)); 38 | 39 | -------------------------------------------------------------------------------- /Lecture/Object in Js/method.js: -------------------------------------------------------------------------------- 1 | let person = { 2 | name: "Admino", 3 | age: 30, 4 | gender: "male", 5 | occupation: "Software Engineer", 6 | hobbies: ["reading", "hiking", "coding"], 7 | address: { 8 | city: "surat", 9 | state: "gujrat", 10 | phone: 99999999 11 | }, 12 | work: true, 13 | }; 14 | 15 | // ========== String methods object ======================= 16 | 17 | // let upperCaseName = person.name.toUpperCase(); 18 | // console.log("Uppercase Name:", upperCaseName); 19 | 20 | // let lowerCaseName = person.name.toLowerCase(); 21 | // console.log("Lowercase Name:", lowerCaseName); 22 | 23 | // let nameLength = person.name.length; 24 | // console.log("Name Length:", nameLength); 25 | 26 | // let replacedName = person.name.replace("Admino", "Godmino"); 27 | // console.log("Replaced Name:", replacedName); 28 | 29 | // let startsWithLetters = person.name.startsWith("Ad"); 30 | // console.log("Starts with 'Ad':", startsWithLetters); 31 | 32 | // let includesLetters = person.name.includes("ino"); 33 | // console.log("Includes 'ino':", includesLetters); 34 | 35 | // let repeatedName = person.name.repeat(3); 36 | // console.log("Repeated Name:", repeatedName); 37 | 38 | // let findChar = person.name.charAt(0); 39 | // console.log("First Character:", findChar); 40 | 41 | // let substringName = person.name.substring(0,4); 42 | // console.log("Substring:", substringName); 43 | 44 | // let nameArray = person.name.split(""); 45 | // console.log("Name Array:", nameArray); 46 | 47 | // ========== Array methods in object ======================= 48 | 49 | let hobbies = person.hobbies 50 | 51 | // hobbies.push('Travelling') 52 | // console.log("Hobbies:", hobbies) 53 | 54 | // hobbies.pop() 55 | // console.log("Hobbies:", hobbies) 56 | 57 | // hobbies.unshift('Travelling') 58 | // console.log("Hobbies:", hobbies) 59 | 60 | // hobbies.shift() 61 | // console.log("Hobbies:", hobbies) 62 | 63 | // let check = hobbies.includes('Travelling') 64 | // console.log(check); 65 | 66 | // let check = hobbies.indexOf('Travelling') 67 | // console.log(check); 68 | // let check = hobbies.indexOf('coding') 69 | // console.log(check); 70 | 71 | // console.log(hobbies.length); 72 | 73 | // console.log(Array.isArray(hobbies)); 74 | 75 | // let newArray = hobbies.forEach((val,i) => { 76 | // console.log(i,val); 77 | // }); 78 | 79 | // let newArray = hobbies.map((val,i) => { 80 | // return val + 'value'; 81 | // }); 82 | // console.log(newArray); 83 | 84 | let filArray = hobbies.filter( val => val !== "coding" ) 85 | console.log(filArray); 86 | 87 | -------------------------------------------------------------------------------- /Lecture/Quets Task/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 10 | 13 | 14 | 15 | 16 | 17 |
18 |
19 |
20 |
21 | 22 |
23 |

24 |

25 |

26 |
27 |
28 |
29 |
30 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Lecture/Quets Task/qoutes-app.js: -------------------------------------------------------------------------------- 1 | let qoutes = 2 | [ 3 | { 4 | "quote": "Be yourself; everyone else is already taken.", 5 | "author": "Oscar Wilde", 6 | "profession": "Irish poet", 7 | "topics": [ 8 | "Inspirational", 9 | "Advice", 10 | "Humor" 11 | ] 12 | }, 13 | { 14 | "quote": "To live is the rarest thing in the world. Most people exist, that is all.", 15 | "author": "Oscar Wilde", 16 | "profession": "Irish poet", 17 | "topics": [ 18 | "Philosophy", 19 | "Humor" 20 | ] 21 | }, 22 | { 23 | "quote": "True friends stab you in the front.", 24 | "author": "Oscar Wilde", 25 | "profession": "Irish poet", 26 | "topics": [ 27 | "Philosophy", 28 | "People" 29 | ] 30 | }, 31 | { 32 | "quote": "Women are made to be Loved, not understood.", 33 | "author": "Oscar Wilde", 34 | "profession": "Irish poet", 35 | "topics": [ 36 | "Philosophy", 37 | "Humor" 38 | ] 39 | }, 40 | { 41 | "quote": "Be the change that you wish to see in the world.", 42 | "author": "Mahatma Gandhi", 43 | "profession": "Indian leader", 44 | "topics": [ 45 | "Inspirational", 46 | "Philosophy", 47 | "Advice" 48 | ] 49 | }, 50 | { 51 | "quote": "Live as if you were to die tomorrow. Learn as if you were to live forever.", 52 | "author": "Mahatma Gandhi", 53 | "profession": "Indian leader", 54 | "topics": [ 55 | "Inspirational", 56 | "Life", 57 | "Advice" 58 | ] 59 | }, 60 | { 61 | "quote": "No one can make you feel inferior without your consent.", 62 | "author": "Eleanor Roosevelt", 63 | "profession": "Former First Lady of the United States", 64 | "topics": [ 65 | "Wisdom" 66 | ] 67 | }, 68 | { 69 | "quote": "Great minds discuss ideas; average minds discuss events; small minds discuss people.", 70 | "author": "Eleanor Roosevelt", 71 | "profession": "Former First Lady of the United States", 72 | "topics": [ 73 | "Wisdom", 74 | "People" 75 | ] 76 | }, 77 | { 78 | "quote": "Do what you feel in your heart to be right - for you'll be criticized anyway.", 79 | "author": "Eleanor Roosevelt", 80 | "profession": "Former First Lady of the United States", 81 | "topics": [ 82 | "Wisdom", 83 | "Advice" 84 | ] 85 | }, 86 | { 87 | "quote": "Do one thing every day that scares you.", 88 | "author": "Eleanor Roosevelt", 89 | "profession": "Former First Lady of the United States", 90 | "topics": [ 91 | "Wisdom", 92 | "Life" 93 | ] 94 | }, 95 | { 96 | "quote": "Darkness cannot drive out darkness: only light can do that. Hate cannot drive out hate; only love can do that.", 97 | "author": "Martin Luther King", 98 | "profession": "American minister", 99 | "topics": [ 100 | "Inspirational", 101 | "Wisdom", 102 | "Love" 103 | ] 104 | }, 105 | { 106 | "quote": "Our lives begin to end the day we become silent about things that matter.", 107 | "author": "Martin Luther King", 108 | "profession": "American minister", 109 | "topics": [ 110 | "Inspirational", 111 | "Life" 112 | ] 113 | }, 114 | { 115 | "quote": "In the end, we will remember not the words of our enemies, but the silence of our friends.", 116 | "author": "Martin Luther King", 117 | "profession": "American minister", 118 | "topics": [ 119 | "People", 120 | "Life" 121 | ] 122 | }, 123 | { 124 | "quote": "Injustice anywhere is a threat to justice everywhere.", 125 | "author": "Martin Luther King", 126 | "profession": "American minister", 127 | "topics": [ 128 | "Wisdom" 129 | ] 130 | }, 131 | { 132 | "quote": "The time is always right to do what is right.", 133 | "author": "Martin Luther King", 134 | "profession": "American minister", 135 | "topics": [ 136 | "Inspirational", 137 | "Wisdom" 138 | ] 139 | }, 140 | { 141 | "quote": "Life's most persistent and urgent question is, 'What are you doing for others?", 142 | "author": "Martin Luther King", 143 | "profession": "American minister", 144 | "topics": [ 145 | "Inspirational", 146 | "Life", 147 | "People" 148 | ] 149 | }, 150 | { 151 | "quote": "Weak people revenge. Strong people forgive. Intelligent People Ignore.", 152 | "author": "Albert Einstein", 153 | "profession": "Theoretical physicist", 154 | "topics": [ 155 | "Inspirational", 156 | "Life" 157 | ] 158 | }, 159 | { 160 | "quote": "I have not failed. I've just found 10,000 ways that won't work.", 161 | "author": "Thomas A. Edison", 162 | "profession": "American inventor", 163 | "topics": [ 164 | "Inspirational" 165 | ] 166 | }, 167 | { 168 | "quote": "Genius is one percent inspiration and ninety-nine percent perspiration.", 169 | "author": "Thomas A. Edison", 170 | "profession": "American inventor", 171 | "topics": [ 172 | "Inspirational", 173 | "Wisdom" 174 | ] 175 | }, 176 | { 177 | "quote": "Our greatest weakness lies in giving up. The most certain way to succeed is always to try just one more time.", 178 | "author": "Thomas A. Edison", 179 | "profession": "American inventor", 180 | "topics": [ 181 | "Inspirational", 182 | "Advice" 183 | ] 184 | }, 185 | { 186 | "quote": "If we did all the things we are capable of, we would literally astound ourselves.", 187 | "author": "Thomas A. Edison", 188 | "profession": "American inventor", 189 | "topics": [ 190 | "Inspirational" 191 | ] 192 | }, 193 | { 194 | "quote": "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world.", 195 | "author": "Albert Einstein", 196 | "profession": "Theoretical physicist", 197 | "topics": [ 198 | "Inspirational", 199 | "Wisdom" 200 | ] 201 | }, 202 | { 203 | "quote": "Life isn't about finding yourself. Life is about creating yourself.", 204 | "author": "George Bernard Shaw", 205 | "profession": "Irish playwright", 206 | "topics": [ 207 | "Inspirational", 208 | "Life", 209 | "Advice" 210 | ] 211 | }, 212 | { 213 | "quote": "Success is not final, failure is not fatal: it is the courage to continue that counts.", 214 | "author": "Winston Churchill", 215 | "profession": "Former British Prime Minister", 216 | "topics": [ 217 | "Inspirational", 218 | "Life", 219 | "Advice" 220 | ] 221 | }, 222 | { 223 | "quote": "If you're going through hell, keep going.", 224 | "author": "Winston Churchill", 225 | "profession": "Former British Prime Minister", 226 | "topics": [ 227 | "Inspirational", 228 | "Advice" 229 | ] 230 | }, 231 | { 232 | "quote": "We make a living by what we get, but we make a life by what we give.", 233 | "author": "Winston Churchill", 234 | "profession": "Former British Prime Minister", 235 | "topics": [ 236 | "People", 237 | "Life" 238 | ] 239 | }, 240 | { 241 | "quote": "Peace begins with a smile.", 242 | "author": "Mother Teresa", 243 | "profession": "Roman Catholic Saint", 244 | "topics": [ 245 | "Inspirational", 246 | "Wisdom" 247 | ] 248 | }, 249 | { 250 | "quote": "Spread love everywhere you go. Let no one ever come to you without leaving happier.", 251 | "author": "Mother Teresa", 252 | "profession": "Roman Catholic Saint", 253 | "topics": [ 254 | "Inspirational", 255 | "Love", 256 | "Advice" 257 | ] 258 | }, 259 | { 260 | "quote": "If you can't feed a hundred people, then feed just one.", 261 | "author": "Mother Teresa", 262 | "profession": "Roman Catholic Saint", 263 | "topics": [ 264 | "Inspirational", 265 | "Advice", 266 | "People" 267 | ] 268 | }, 269 | { 270 | "quote": "Kind words can be short and easy to speak, but their echoes are truly endless.", 271 | "author": "Mother Teresa", 272 | "profession": "Roman Catholic Saint", 273 | "topics": [ 274 | "Inspirational", 275 | "People" 276 | ] 277 | }, 278 | { 279 | "quote": "Isn't it nice to think that tomorrow is a new day with no mistakes in it yet?", 280 | "author": "L.M. Montgomery", 281 | "profession": "Canadian author", 282 | "topics": [ 283 | "Inspirational" 284 | ] 285 | }, 286 | { 287 | "quote": "Tomorrow is always fresh, with no mistakes in it.", 288 | "author": "L.M. Montgomery", 289 | "profession": "Canadian author", 290 | "topics": [ 291 | "Inspirational" 292 | ] 293 | }, 294 | { 295 | "quote": "We should regret our mistakes and learn from them, but never carry them forward into the future with us.", 296 | "author": "L.M. Montgomery", 297 | "profession": "Canadian author", 298 | "topics": [ 299 | "Inspirational", 300 | "Advice", 301 | "Life" 302 | ] 303 | }, 304 | ] 305 | 306 | let getQuete = (queteNum) => { 307 | queteNum = Math.floor(Math.random() * 10); 308 | 309 | console.log(qoutes [queteNum]); 310 | 311 | document.getElementById("quote").innerHTML = `"${qoutes[queteNum].quote}"` 312 | document.getElementById("author").innerHTML = `"${qoutes[queteNum].author}"` 313 | document.getElementById("profession").innerHTML = `"${qoutes[queteNum].quote}"` 314 | 315 | } -------------------------------------------------------------------------------- /Lecture/Quets Task/quote-slider.js: -------------------------------------------------------------------------------- 1 | let quotes = 2 | [ 3 | { 4 | "quote": "Be yourself; everyone else is already taken.", 5 | "author": "Oscar Wilde", 6 | "profession": "Irish poet", 7 | "topics": [ 8 | "Inspirational", 9 | "Advice", 10 | "Humor" 11 | ] 12 | }, 13 | { 14 | "quote": "To live is the rarest thing in the world. Most people exist, that is all.", 15 | "author": "Oscar Wilde", 16 | "profession": "Irish poet", 17 | "topics": [ 18 | "Philosophy", 19 | "Humor" 20 | ] 21 | }, 22 | { 23 | "quote": "True friends stab you in the front.", 24 | "author": "Oscar Wilde", 25 | "profession": "Irish poet", 26 | "topics": [ 27 | "Philosophy", 28 | "People" 29 | ] 30 | }, 31 | { 32 | "quote": "Women are made to be Loved, not understood.", 33 | "author": "Oscar Wilde", 34 | "profession": "Irish poet", 35 | "topics": [ 36 | "Philosophy", 37 | "Humor" 38 | ] 39 | }, 40 | { 41 | "quote": "Be the change that you wish to see in the world.", 42 | "author": "Mahatma Gandhi", 43 | "profession": "Indian leader", 44 | "topics": [ 45 | "Inspirational", 46 | "Philosophy", 47 | "Advice" 48 | ] 49 | }, 50 | { 51 | "quote": "Live as if you were to die tomorrow. Learn as if you were to live forever.", 52 | "author": "Mahatma Gandhi", 53 | "profession": "Indian leader", 54 | "topics": [ 55 | "Inspirational", 56 | "Life", 57 | "Advice" 58 | ] 59 | }, 60 | { 61 | "quote": "No one can make you feel inferior without your consent.", 62 | "author": "Eleanor Roosevelt", 63 | "profession": "Former First Lady of the United States", 64 | "topics": [ 65 | "Wisdom" 66 | ] 67 | }, 68 | { 69 | "quote": "Great minds discuss ideas; average minds discuss events; small minds discuss people.", 70 | "author": "Eleanor Roosevelt", 71 | "profession": "Former First Lady of the United States", 72 | "topics": [ 73 | "Wisdom", 74 | "People" 75 | ] 76 | }, 77 | { 78 | "quote": "Do what you feel in your heart to be right - for you'll be criticized anyway.", 79 | "author": "Eleanor Roosevelt", 80 | "profession": "Former First Lady of the United States", 81 | "topics": [ 82 | "Wisdom", 83 | "Advice" 84 | ] 85 | }, 86 | { 87 | "quote": "Do one thing every day that scares you.", 88 | "author": "Eleanor Roosevelt", 89 | "profession": "Former First Lady of the United States", 90 | "topics": [ 91 | "Wisdom", 92 | "Life" 93 | ] 94 | }, 95 | { 96 | "quote": "Darkness cannot drive out darkness: only light can do that. Hate cannot drive out hate; only love can do that.", 97 | "author": "Martin Luther King", 98 | "profession": "American minister", 99 | "topics": [ 100 | "Inspirational", 101 | "Wisdom", 102 | "Love" 103 | ] 104 | }, 105 | { 106 | "quote": "Our lives begin to end the day we become silent about things that matter.", 107 | "author": "Martin Luther King", 108 | "profession": "American minister", 109 | "topics": [ 110 | "Inspirational", 111 | "Life" 112 | ] 113 | }, 114 | { 115 | "quote": "In the end, we will remember not the words of our enemies, but the silence of our friends.", 116 | "author": "Martin Luther King", 117 | "profession": "American minister", 118 | "topics": [ 119 | "People", 120 | "Life" 121 | ] 122 | }, 123 | { 124 | "quote": "Injustice anywhere is a threat to justice everywhere.", 125 | "author": "Martin Luther King", 126 | "profession": "American minister", 127 | "topics": [ 128 | "Wisdom" 129 | ] 130 | }, 131 | { 132 | "quote": "The time is always right to do what is right.", 133 | "author": "Martin Luther King", 134 | "profession": "American minister", 135 | "topics": [ 136 | "Inspirational", 137 | "Wisdom" 138 | ] 139 | }, 140 | { 141 | "quote": "Life's most persistent and urgent question is, 'What are you doing for others?", 142 | "author": "Martin Luther King", 143 | "profession": "American minister", 144 | "topics": [ 145 | "Inspirational", 146 | "Life", 147 | "People" 148 | ] 149 | }, 150 | { 151 | "quote": "Weak people revenge. Strong people forgive. Intelligent People Ignore.", 152 | "author": "Albert Einstein", 153 | "profession": "Theoretical physicist", 154 | "topics": [ 155 | "Inspirational", 156 | "Life" 157 | ] 158 | }, 159 | { 160 | "quote": "I have not failed. I've just found 10,000 ways that won't work.", 161 | "author": "Thomas A. Edison", 162 | "profession": "American inventor", 163 | "topics": [ 164 | "Inspirational" 165 | ] 166 | }, 167 | { 168 | "quote": "Genius is one percent inspiration and ninety-nine percent perspiration.", 169 | "author": "Thomas A. Edison", 170 | "profession": "American inventor", 171 | "topics": [ 172 | "Inspirational", 173 | "Wisdom" 174 | ] 175 | }, 176 | { 177 | "quote": "Our greatest weakness lies in giving up. The most certain way to succeed is always to try just one more time.", 178 | "author": "Thomas A. Edison", 179 | "profession": "American inventor", 180 | "topics": [ 181 | "Inspirational", 182 | "Advice" 183 | ] 184 | }, 185 | { 186 | "quote": "If we did all the things we are capable of, we would literally astound ourselves.", 187 | "author": "Thomas A. Edison", 188 | "profession": "American inventor", 189 | "topics": [ 190 | "Inspirational" 191 | ] 192 | }, 193 | { 194 | "quote": "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world.", 195 | "author": "Albert Einstein", 196 | "profession": "Theoretical physicist", 197 | "topics": [ 198 | "Inspirational", 199 | "Wisdom" 200 | ] 201 | }, 202 | { 203 | "quote": "Life isn't about finding yourself. Life is about creating yourself.", 204 | "author": "George Bernard Shaw", 205 | "profession": "Irish playwright", 206 | "topics": [ 207 | "Inspirational", 208 | "Life", 209 | "Advice" 210 | ] 211 | }, 212 | { 213 | "quote": "Success is not final, failure is not fatal: it is the courage to continue that counts.", 214 | "author": "Winston Churchill", 215 | "profession": "Former British Prime Minister", 216 | "topics": [ 217 | "Inspirational", 218 | "Life", 219 | "Advice" 220 | ] 221 | }, 222 | { 223 | "quote": "If you're going through hell, keep going.", 224 | "author": "Winston Churchill", 225 | "profession": "Former British Prime Minister", 226 | "topics": [ 227 | "Inspirational", 228 | "Advice" 229 | ] 230 | }, 231 | { 232 | "quote": "We make a living by what we get, but we make a life by what we give.", 233 | "author": "Winston Churchill", 234 | "profession": "Former British Prime Minister", 235 | "topics": [ 236 | "People", 237 | "Life" 238 | ] 239 | }, 240 | { 241 | "quote": "Peace begins with a smile.", 242 | "author": "Mother Teresa", 243 | "profession": "Roman Catholic Saint", 244 | "topics": [ 245 | "Inspirational", 246 | "Wisdom" 247 | ] 248 | }, 249 | { 250 | "quote": "Spread love everywhere you go. Let no one ever come to you without leaving happier.", 251 | "author": "Mother Teresa", 252 | "profession": "Roman Catholic Saint", 253 | "topics": [ 254 | "Inspirational", 255 | "Love", 256 | "Advice" 257 | ] 258 | }, 259 | { 260 | "quote": "If you can't feed a hundred people, then feed just one.", 261 | "author": "Mother Teresa", 262 | "profession": "Roman Catholic Saint", 263 | "topics": [ 264 | "Inspirational", 265 | "Advice", 266 | "People" 267 | ] 268 | }, 269 | { 270 | "quote": "Kind words can be short and easy to speak, but their echoes are truly endless.", 271 | "author": "Mother Teresa", 272 | "profession": "Roman Catholic Saint", 273 | "topics": [ 274 | "Inspirational", 275 | "People" 276 | ] 277 | }, 278 | { 279 | "quote": "Isn't it nice to think that tomorrow is a new day with no mistakes in it yet?", 280 | "author": "L.M. Montgomery", 281 | "profession": "Canadian author", 282 | "topics": [ 283 | "Inspirational" 284 | ] 285 | }, 286 | { 287 | "quote": "Tomorrow is always fresh, with no mistakes in it.", 288 | "author": "L.M. Montgomery", 289 | "profession": "Canadian author", 290 | "topics": [ 291 | "Inspirational" 292 | ] 293 | }, 294 | { 295 | "quote": "We should regret our mistakes and learn from them, but never carry them forward into the future with us.", 296 | "author": "L.M. Montgomery", 297 | "profession": "Canadian author", 298 | "topics": [ 299 | "Inspirational", 300 | "Advice", 301 | "Life" 302 | ] 303 | }, 304 | ] 305 | 306 | let currentIndex = 0; 307 | 308 | const displayQuote = () => { 309 | const { quote, author, profession } = quotes[currentIndex]; 310 | document.getElementById("quote").innerText = `"${quote}"`; 311 | document.getElementById("author").innerText = `- ${author}`; 312 | document.getElementById("profession").innerText = profession; 313 | }; 314 | 315 | const prevQuote = () => { 316 | currentIndex = (currentIndex === 0) ? quotes.length - 1 : currentIndex - 1; 317 | displayQuote(); 318 | }; 319 | 320 | const nextQuote = () => { 321 | currentIndex = (currentIndex === quotes.length - 1) ? 0 : currentIndex + 1; 322 | displayQuote(); 323 | }; 324 | 325 | setInterval(nextQuote, 6000); 326 | 327 | displayQuote(); -------------------------------------------------------------------------------- /Lecture/Quets Task/slider.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Quote Slider 8 | 10 | 13 | 14 | 15 | 16 | 17 |
18 |
19 |
20 |
21 |

22 |

23 |

24 |
25 | 26 | 27 |
28 |
29 |
30 |
31 |
32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Logical-Tasks/armstrong_num.js: -------------------------------------------------------------------------------- 1 | // for (let num = 1; num <= 1000; num++) { 2 | // let originalNum = num; 3 | // let sum = 0; 4 | // let temp = num; 5 | // let count = 0; 6 | 7 | // while (temp > 0) { 8 | // count++; 9 | // temp = Math.floor(temp / 10); 10 | // } 11 | 12 | // temp = num; 13 | 14 | // while (temp > 0) { 15 | // let digit = temp % 10; 16 | // sum += Math.pow(digit, count); 17 | // temp = Math.floor(temp / 10); 18 | // } 19 | 20 | // if (sum === originalNum) { 21 | // console.log(originalNum); 22 | // } 23 | // } 24 | -------------------------------------------------------------------------------- /Logical-Tasks/decimal.js: -------------------------------------------------------------------------------- 1 | // ========== Binary To Decimal =================== 2 | 3 | const binary = prompt("Enter a binary number:"); 4 | 5 | if (/^[01]+$/.test(binary)) { 6 | const decimal = parseInt(binary, 2); 7 | console.log(`The decimal equivalent of binary ${binary} is ${decimal}.`); 8 | } else { 9 | console.log("Invalid input. Please enter a valid binary number (only 0s and 1s)."); 10 | } -------------------------------------------------------------------------------- /Logical-Tasks/fibonacci.js: -------------------------------------------------------------------------------- 1 | // ========== Fibonacci Series =================== 2 | 3 | let n = parseInt(prompt("Enter the number of terms :")) 4 | let num1 = 0, num2 = 1; 5 | let num3; 6 | 7 | num3 = num1 + num2; 8 | 9 | console.log("fibonacci Series : "); 10 | console.log(num1); 11 | console.log(num2); 12 | 13 | for (let i = 3; i <= n; i++) { 14 | console.log(num3); 15 | num1 = num2; 16 | num2 = num3; 17 | num3 = num1 + num2 18 | } -------------------------------------------------------------------------------- /Logical-Tasks/find_arm.js: -------------------------------------------------------------------------------- 1 | let num = parseInt(prompt('Enter a number between 1 to 1000:')); 2 | 3 | if (num < 1 || num > 1000) { 4 | alert('Enter a number between 1 to 1000'); 5 | } else { 6 | console.log(`Armstrong numbers from 1 to ${num}:`); 7 | let foundArmstrong = false; 8 | 9 | for (let i = 1; i <= num; i++) { 10 | if (isArmstrong(i)) { 11 | console.log(i); 12 | foundArmstrong = true; 13 | } 14 | } 15 | 16 | if (!foundArmstrong) { 17 | console.log(`${num} is not an Armstrong number.`); 18 | } 19 | } 20 | 21 | function isArmstrong(number) { 22 | const digits = number.toString().split(''); 23 | const numDigits = digits.length; 24 | const sum = digits.reduce((acc, digit) => acc + Math.pow(parseInt(digit), numDigits), 0); 25 | return sum === number; 26 | } -------------------------------------------------------------------------------- /Logical-Tasks/interview_tasks/logic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Logical Tasks 7 | 8 | 9 |

Logical Tasks

10 | 11 | 12 | -------------------------------------------------------------------------------- /Logical-Tasks/interview_tasks/pattern.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Patterns in Js 7 | 8 | 9 |

Patterns In Js

10 | 11 | 12 | -------------------------------------------------------------------------------- /Logical-Tasks/interview_tasks/pattern.js: -------------------------------------------------------------------------------- 1 | // 1 2 | // 1 2 3 | // 1 2 3 4 | // 1 2 3 4 5 | // 1 2 3 4 5 6 | 7 | // for (let i = 1; i <= 5; i++) { 8 | // let row = ""; 9 | // for (let j = 1; j <= i; j++) { 10 | // row += j + " " 11 | // } 12 | // console.log(row); 13 | // } 14 | 15 | // 1 16 | // 2 2 17 | // 3 3 3 18 | // 4 4 4 4 19 | // 5 5 5 5 5 20 | 21 | // for (let i = 1; i <= 5; i++) { 22 | // let row = ""; 23 | // for (let j = 1; j <= i; j++) { 24 | // row += i + " " 25 | // } 26 | // console.log(row); 27 | // } 28 | 29 | // 5 30 | // 5 4 31 | // 5 4 3 32 | // 5 4 3 2 33 | // 5 4 3 2 1 34 | 35 | // for(let i=5; i>=1; i--) { 36 | // let row = ""; 37 | // for(let j=5; j>=i; j--){ 38 | // row += j + " " 39 | // } 40 | // console.log(row); 41 | 42 | // } 43 | 44 | // 5 45 | // 4 4 46 | // 3 3 3 47 | // 2 2 2 2 48 | // 1 1 1 1 1 49 | 50 | // for (let i = 5; i >= 1; i--) { 51 | // let row = ""; 52 | // for (let j = 5; j >= i; j--) { 53 | // row += i + " " 54 | // } 55 | // console.log(row); 56 | // } 57 | 58 | // 1 59 | // 2 1 60 | // 3 2 1 61 | // 4 3 2 1 62 | // 5 4 3 2 1 63 | 64 | // for(let i=1;i<=5;i++){ 65 | // let row = ""; 66 | // for(let j=i;j>=1;j--){ 67 | // row += j + " " 68 | // } 69 | // console.log(row); 70 | // } 71 | 72 | // 5 73 | // 4 5 74 | // 3 4 5 75 | // 2 3 4 5 76 | // 1 2 3 4 5 77 | 78 | // for(let i=5;i>=1;i--){ 79 | // let row = ""; 80 | // for(let j=i;j<=5;j++){ 81 | // row += j + " "; 82 | // } 83 | // console.log(row); 84 | // } 85 | 86 | // **************************************************************************************************** 87 | 88 | // 5 4 3 2 1 89 | // 5 4 3 2 90 | // 5 4 3 91 | // 5 4 92 | // 5 93 | 94 | // for (let i = 1; i <= 5; i++) { 95 | // let row = ""; 96 | // for (let j = 5; j >= i; j--) { 97 | // row += j + " " 98 | // } 99 | // console.log(row); 100 | // } 101 | 102 | // 1 1 1 1 1 103 | // 2 2 2 2 104 | // 3 3 3 105 | // 4 4 106 | // 5 107 | 108 | // for (let i = 1; i <= 5; i++) { 109 | // let row = ""; 110 | // for (let j = 5; j >= i; j--) { 111 | // row += i + " " 112 | // } 113 | // console.log(row); 114 | // } 115 | 116 | // 5 4 3 2 1 117 | // 4 3 2 1 118 | // 3 2 1 119 | // 2 1 120 | // 1 121 | 122 | // for(let i=5; i>=1; i--){ 123 | // let row = ""; 124 | // for(let j=i; j>=1; j--){ 125 | // row += j + " " 126 | // } 127 | // console.log(row); 128 | // } 129 | 130 | // 5 5 5 5 5 131 | // 4 4 4 4 132 | // 3 3 3 133 | // 2 2 134 | // 1 135 | 136 | // for(let i=5; i>=1; i--){ 137 | // let row = ""; 138 | // for(let j=i; j>=1; j--){ 139 | // row += i + " " 140 | // } 141 | // console.log(row); 142 | // } 143 | 144 | // * * * * * 145 | // * * * * 146 | // * * * 147 | // * * 148 | // * 149 | 150 | // for(let i=5; i>=1; i--){ 151 | // let row = ""; 152 | // for(let j=i; j>=1; j--){ 153 | // row += "*" + " " 154 | // } 155 | // console.log(row); 156 | // } -------------------------------------------------------------------------------- /Logical-Tasks/interview_tasks/task_01.js: -------------------------------------------------------------------------------- 1 | // Wap to print sum of digit in a number ---------------------------------------------------------------------------------------------------- 2 | 3 | // let num = Number(prompt("Enter Any Number")) 4 | // let sum = 0 5 | 6 | // while(num > 0){ 7 | // sum += num % 10; 8 | // num = Math.floor(num / 10); 9 | // } 10 | // console.log(sum); 11 | 12 | 13 | // Wap to print sum of 1st abd Last digit in a number ---------------------------------------------------------------------------------------------------- 14 | 15 | // let num = Number(prompt("Enter Any Number")) 16 | // let sum = 0; 17 | // let ld = num % 10, fd; 18 | 19 | // while (num >= 10) { 20 | // num = (num - (num % 10)) / 10; 21 | // fd = num; 22 | // sum = fd + ld; 23 | // } 24 | // console.log(sum); 25 | 26 | // Swap A 2 variable using 3rd variable ---------------------------------------------------------------------------------------------------- 27 | 28 | // let a = 5 29 | // let b = 1 30 | // let c = a 31 | 32 | // a = b; 33 | // b = c 34 | // c = a 35 | // console.log(a,b,c) 36 | 37 | // Swap A 3 variable using 4th variable ---------------------------------------------------------------------------------------------------- 38 | 39 | // let a = 10 , b = 20 , c = 30 , temp; 40 | 41 | // temp = a; 42 | // a = b; 43 | // b = c; 44 | // c = temp; 45 | // console.log(a,b,c); 46 | 47 | // Swap A 2 variable without using 3rd variable ---------------------------------------------------------------------------------------------------- 48 | 49 | // let a = 10 , b = 20; 50 | 51 | // a = a + b; // 10+20 = 30 52 | // b = a - b // 30-20 = 10 53 | // a = a - b // 30-10 = 20 54 | 55 | // console.log(a,b); 56 | 57 | // Swap A 3 variable without using 4th variable ---------------------------------------------------------------------------------------------------- 58 | 59 | // let a = 10, b = 20, c = 30; 60 | 61 | // a = a + b + c; // 10+20+30 = 60 62 | // b = a - b - c; // 60-20-30 = 10 63 | // c = a - b - c; // 60-10-30 = 20 64 | // a = a - b - c; // 60-10-20 = 30 65 | 66 | // console.log(a, b, c); 67 | 68 | // WAP to FIND Factor of a number ---------------------------------------------------------------------------------------------------- 69 | 70 | // let num = Number(prompt("Enter Any Number")); 71 | // let i = 1; 72 | 73 | // // While Loop 74 | 75 | // while (i <= num) { 76 | // if (num % i == 0) { 77 | // console.log(i); 78 | // } 79 | // i++; 80 | // } 81 | 82 | // For Loop 83 | 84 | // for (i; i <= num; i++) { 85 | // if (num % i == 0) { 86 | // console.log(i); 87 | // } 88 | // } 89 | 90 | // WAP to FIND Factorial of a number ---------------------------------------------------------------------------------------------------- 91 | 92 | // let num = Number(prompt("Enter Any Number")); 93 | // let fact = 1; 94 | // let i = 1 95 | 96 | // While Loop 97 | 98 | // while (i <= num) { 99 | // fact *= i 100 | // i++; 101 | // } 102 | 103 | // For Loop 104 | 105 | // let num = Number(prompt("Enter Any Number")); 106 | // let fact = 1; 107 | // let i = num 108 | 109 | // for (i; i >= 1; i--) { 110 | // fact *= i; 111 | // } 112 | 113 | // console.log("factorial => " + fact); 114 | 115 | // WAP to print fibbonacci sereas ---------------------------------------------------------------------------------------------------- 116 | 117 | // let num = Number(prompt("ENTER ANY NUMBER")); 118 | // let a = 0; 119 | // let b = 1; 120 | // let next; 121 | // let i = 2; 122 | 123 | // While Loop 124 | 125 | // while( i < num){ 126 | // next = a + b; 127 | // console.log(next); 128 | // a = b; 129 | // b = next; 130 | // i++ 131 | // } 132 | 133 | // For Loop 134 | 135 | // for (i; i <= num; i++) { 136 | // next = a + b; 137 | // console.log(next); 138 | // a = b; 139 | // b = next; 140 | // } 141 | 142 | // WAP to check prime number ---------------------------------------------------------------------------------------------------- 143 | let num = Number(prompt("ENTER ANY NUMBER")); 144 | let i = 2; 145 | 146 | // While Loop 147 | 148 | while (i < num) { 149 | if (num % i == 0) { 150 | console.log("Not Prime"); 151 | break; 152 | } 153 | i++; 154 | } 155 | 156 | if (i == num) { 157 | console.log("Prime Number"); 158 | } 159 | 160 | // WAP to check ArmStrong number ---------------------------------------------------------------------------------------------------- 161 | 162 | // let num = Number(prompt("Enter any Number")); 163 | // let sum = 0; 164 | // let digits = 0; 165 | 166 | // for (let temp = num; temp > 0; temp = Math.floor(temp / 10)) { 167 | // digits++; 168 | // } 169 | 170 | // for (let temp = num; temp > 0; temp = Math.floor(temp / 10)) { 171 | // let rem = temp % 10; 172 | // sum = sum + Math.pow(rem, digits); 173 | // } 174 | 175 | // if (sum == num) { 176 | // console.log("Armstrong"); 177 | 178 | // } else { 179 | // console.log("NOt Armstrong"); 180 | // } -------------------------------------------------------------------------------- /Logical-Tasks/oop.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | QS - 3 8 | 9 | 10 | 12 | 15 | 18 | 21 | 22 | 23 | 24 |
25 |

Multiplication Table

26 | 27 | 28 | 29 |
30 |
31 | 32 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /Logical-Tasks/patterns.js: -------------------------------------------------------------------------------- 1 | // 1 2 3 4 5 2 | // 6 7 8 9 3 | // 10 11 12 4 | // 13 14 5 | // 15 6 | // let n = 1; 7 | // for (let i = 1; i <= 5; i++) { 8 | // for (let j = i; j <= 5; j++) { 9 | // process.stdout.write(n + ' '); 10 | // n++; 11 | // } 12 | // process.stdout.write('\n'); 13 | 14 | // } 15 | 16 | 17 | // 15 14 13 12 11 18 | // 10 9 8 7 19 | // 6 5 4 20 | // 3 2 21 | // 1 22 | 23 | // let n = 15; 24 | // for (let i = 1; i <= 5; i++) { 25 | // for (let j = i; j <= 5; j++) { 26 | // process.stdout.write(n + ' '); 27 | // n--; 28 | // } 29 | // process.stdout.write('\n'); 30 | 31 | // } 32 | 33 | 34 | // 1 2 3 4 5 35 | // 1 2 3 4 36 | // 1 2 3 37 | // 1 2 38 | // 1 39 | 40 | // for (let i = 1; i <= 5; i++) { 41 | // for (let j = 1; j <= 6 - i; j++) { 42 | // process.stdout.write(j + ' '); 43 | // } 44 | // process.stdout.write('\n'); 45 | // } 46 | 47 | 48 | // 1 2 3 4 5 49 | // 2 3 4 5 50 | // 3 4 5 51 | // 4 5 52 | // 5 53 | 54 | // for (let i = 1; i <= 5; i++) { 55 | // for (let j = i; j <= 5; j++) { 56 | // process.stdout.write(j + ' '); 57 | // } 58 | // process.stdout.write('\n'); 59 | 60 | // } 61 | 62 | // 5 4 3 2 1 63 | // 4 3 2 1 64 | // 3 2 1 65 | // 2 1 66 | // 1 67 | 68 | // for (let i = 1; i <= 5; i++) { 69 | // for (let j = 6-i; j >= 1; j--) { 70 | // process.stdout.write(j + ' '); 71 | // } 72 | // process.stdout.write('\n'); 73 | // } 74 | 75 | // 5 4 3 2 1 76 | // 5 4 3 2 77 | // 5 4 3 78 | // 5 4 79 | // 5 80 | 81 | // for (let i = 1; i <= 5; i++) { 82 | // for (let j = 5; j >= i; j--) { 83 | // process.stdout.write(j + ' '); 84 | // } 85 | // process.stdout.write('\n'); 86 | // } 87 | 88 | // 1 89 | // 2 3 90 | // 4 5 6 91 | // 7 8 9 10 92 | // 11 12 13 14 15 93 | 94 | // let n = 1; 95 | 96 | // for (let i = 1; i <= 5; i++) { 97 | // for (let j = 1; j <= i; j++) { 98 | // process.stdout.write(n + ' '); 99 | // n++ 100 | // } 101 | // process.stdout.write('\n'); 102 | // } -------------------------------------------------------------------------------- /Logical-Tasks/pelindrome_num.js: -------------------------------------------------------------------------------- 1 | for (let num = 1; num <= 100; num++) { 2 | let temp = num, rev = 0, rem; 3 | 4 | while (temp > 0) { 5 | rem = temp % 10; 6 | rev = (rev * 10) + rem; 7 | temp = Math.floor(temp / 10); 8 | } 9 | 10 | if (rev === num) { 11 | console.log(num); 12 | } 13 | } 14 | 15 | // let num = parseInt(prompt("Enter a number:")); 16 | // let temp = num, rev = 0, rem; 17 | 18 | // while (temp > 0) { 19 | // rem = temp % 10; 20 | // rev = (rev * 10) + rem; 21 | // temp = Math.floor(temp / 10); 22 | // } 23 | 24 | // if (rev === num) { 25 | // console.log(`${num} is a Palindrome`); 26 | // } else { 27 | // console.log(`${num} is NOT a Palindrome`); 28 | // } 29 | -------------------------------------------------------------------------------- /Logical-Tasks/print.js: -------------------------------------------------------------------------------- 1 | // ============ Basic CalC ==================== 2 | 3 | let a = parseInt(prompt("enter any number")); 4 | let b = parseInt(prompt("enter 2nd number")); 5 | 6 | let addition = a+b; 7 | let substraction = a-b; 8 | let Multipication = a*b; 9 | let division = a/b; 10 | console.log(addition); 11 | console.log(substraction); 12 | console.log(Multipication); 13 | console.log(division); -------------------------------------------------------------------------------- /Logical-Tasks/remove_dup.js: -------------------------------------------------------------------------------- 1 | let arr = [1,2,3,3,2,1,4,5,5,4]; 2 | let newArr = []; 3 | let index = 0; 4 | 5 | for (let i = 0; i < arr.length; i++) { 6 | let flag = 1; 7 | 8 | for (let j = 0; j < index; j++) { 9 | if (arr[i] === newArr[j]) { 10 | flag = 0; 11 | break; 12 | } 13 | } 14 | 15 | if (flag == 1) { 16 | newArr[index] = arr[i]; 17 | index++; 18 | } 19 | } 20 | 21 | console.log(newArr); 22 | -------------------------------------------------------------------------------- /Logical-Tasks/task.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Tasks 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Practice/OOP/calc.js: -------------------------------------------------------------------------------- 1 | class TipCalc { 2 | constructor(billAmount, persons) { 3 | this.billAmount = billAmount; 4 | this.persons = persons; 5 | this.tipAmmount = this.claculateTip(); 6 | this.total = this.billAmount + this.tipAmmount; 7 | } 8 | 9 | claculateTip() { 10 | if (this.billAmount > 0 && this.billAmount < 100) { 11 | return 10; 12 | } else if (this.billAmount >= 100 && this.billAmount < 500) { 13 | return 50; 14 | } else if (this.billAmount >= 500 && this.billAmount < 1000) { 15 | return 100; 16 | } else if (this.billAmount > 1000) { 17 | return 150; 18 | } else { 19 | return 0; 20 | } 21 | } 22 | 23 | perPersonBill() { 24 | return this.billAmount / this.persons; 25 | } 26 | 27 | perPersonTip() { 28 | return this.tipAmmount / this.persons; 29 | } 30 | 31 | displayDetails() { 32 | alert(` Bill Amount : ₹${this.billAmount} 33 | Tip Ammoutn : ₹${this.tipAmmount} 34 | Total Amount : ₹${this.total} 35 | Bill per Person : ₹${this.perPersonBill()} 36 | Tip per Person : ₹${this.perPersonTip()} 37 | `); 38 | } 39 | } 40 | 41 | let billAmount = parseInt(prompt("Enter the bill amount:")); 42 | let persons = parseInt(prompt("Enter the number of persons:")); 43 | 44 | if (isNaN(billAmount) || billAmount > 5000 || isNaN(persons) || persons <= 0) { 45 | alert("Please Enter the valid Numbers") 46 | } else { 47 | let tipCalculator = new TipCalc(billAmount, persons); 48 | tipCalculator.displayDetails(); 49 | } -------------------------------------------------------------------------------- /Practice/OOP/constructor.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Constructor 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Practice/OOP/constructor.js: -------------------------------------------------------------------------------- 1 | class Car { 2 | constructor(name,color){ 3 | this.name = name; 4 | this.color = color; 5 | } 6 | carInfo() { 7 | console.log(`this car is ${this.name} in ${this.color} color`); 8 | } 9 | }; 10 | 11 | 12 | let carData = new Car('Toyota','Black'); 13 | let carData2 = new Car('Bmw','Gray'); 14 | 15 | carData.carInfo(); 16 | carData2.carInfo(); 17 | -------------------------------------------------------------------------------- /Practice/OOP/inheritance.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | OOP 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Practice/OOP/inheritance.js: -------------------------------------------------------------------------------- 1 | 2 | class Minato { 3 | // constructor() { 4 | // this.name = name; 5 | // } 6 | showJutsu () { 7 | console.log("Minato's Jutsu: Rasengan"); 8 | } 9 | } 10 | 11 | class Naruto extends Minato { 12 | // constructor(name) { 13 | // this.name = name; 14 | // } 15 | showAbility () { 16 | this.showJutsu(); 17 | console.log("Naruto's Ability: Nine-Tails Chakra"); 18 | } 19 | } 20 | 21 | let obj = new Naruto(); 22 | 23 | obj.showJutsu(); 24 | -------------------------------------------------------------------------------- /Practice/OOP/tipCalc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Tip Calculator 7 | 8 | 9 |

Tip Calculator

10 | 11 | 12 | --------------------------------------------------------------------------------