{"id":18671954,"url":"https://github.com/lucky-kashyap/js-interview-practice","last_synced_at":"2026-02-07T15:07:34.683Z","repository":{"id":197009326,"uuid":"697806539","full_name":"Lucky-Kashyap/JS-interview-practice","owner":"Lucky-Kashyap","description":"javascript interview prep practice theory and problem solving","archived":false,"fork":false,"pushed_at":"2024-05-29T17:03:54.000Z","size":242,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-15T00:25:29.768Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Lucky-Kashyap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-09-28T14:11:22.000Z","updated_at":"2024-05-29T17:03:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb053a50-4a56-41b1-a034-44cd382f55de","html_url":"https://github.com/Lucky-Kashyap/JS-interview-practice","commit_stats":null,"previous_names":["lucky-kashyap/js-interview-practice"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Lucky-Kashyap/JS-interview-practice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lucky-Kashyap%2FJS-interview-practice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lucky-Kashyap%2FJS-interview-practice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lucky-Kashyap%2FJS-interview-practice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lucky-Kashyap%2FJS-interview-practice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lucky-Kashyap","download_url":"https://codeload.github.com/Lucky-Kashyap/JS-interview-practice/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lucky-Kashyap%2FJS-interview-practice/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29197774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T14:35:27.868Z","status":"ssl_error","status_checked_at":"2026-02-07T14:25:51.081Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T09:08:54.658Z","updated_at":"2026-02-07T15:07:34.655Z","avatar_url":"https://github.com/Lucky-Kashyap.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JS-interview-practice\n\njavascript interview prep practice theory and problem solving\n\n#Solving theory questions as well as some problem solving based on arrays , string \u0026 object.\n\n### var vs let vs const\n\nvar has globl scope or function scope\n\n- we can delclare it as many times as we want.\n- value can redeclare and reinitialize.\n\n      var a = 5;\n\n      var a =  10;\n\n      console.log(a);\n\nlet has block scope\n\n- we can declare it with let keyword and can be accessed with that specific block\n- redeclaration of let variable not allowed.\n\n      // let num = 20;\n\n      console.log(num);\n\n      {\n          let a = 20;\n      }\n\n      console.log(a);\n\n        {\n           let a = 20;\n        }\n\n      console.log(a);\n\nconst has also block\n\n- declare it only one time and we can not mutate value of const variable\n- redeclaration not allowed.\n\n      const age = 20;\n\n      console.log(a);\n\n      {\n        const a = 10;\n        console.log(a);\n      }\n\n      console.log(age);\n      console.log(a);  // give error\n\n### Hoisting: It means moving variables declaration \u0026 functions are top of the scope\n\n      console.log(count);\n\n      var count = 30;\n\n      console.log(num);\n\n      let num=10;\n\n      console.log(PI);\n\n      const PI = 3.14;\n\n      let num = 10;\n      var num =20;\n\n      var num = 20;\n\n      let num = 10;\n\nvar is hoisted but let a \u0026 const hoist in TDZ\n\n### Functions in JS :\n\n- function expression\n- function statement\n- function declaration\n- Anonymous function\n- Arrow Function ()=\u003e{}\n- first class function:\n\nbasically it is variable like function it can be assigned\n\nfunction can be passed to another function\n\n        function square(num){\n          console.log(num*num);\n        }\n\n        var square = function(num){\n          console.log(num*num);\n        }\n\n- IIFE: Immediately invoked function\n\n      (function square(num){\n         return num* num;\n       console.log(num * num);\n      })(10);\n\n      (function(x){\n         return (function(y){\n           console.log(x);\n        })(2);\n       })(1);\n\n### Arrow function vs regular function:\n\n    function square(num){\n        return num * num;\n    }\n\n    const square = (num)=\u003e{\n      return num * num;\n    }\n\nAbout 'this' keyword:\n\n        console.log(this);\n\n        function fn(){\n          console.log(this);\n        }\n\n        fn();\n\n### Truthy \u0026 Falsy values:\n\n0,null,'',{},-0,false,undefined,Infinity,-Infinity are falsy values\n\n\u0026 all other are truthy values\n\n          if(true){\n            console.log('truthy');\n          }\n\n          if(0){\n            console.log('falsy value');\n          }\n\n### Solving Array Based Questions logical Based:\n\n1.  How do you check if an element exits in an array?\n\n          const findElement = (arr, target) =\u003e {\n          for (let x of arr) {\n            console.log(x);\n            if (x == target) {\n              return true;\n            }\n          }\n          return false;\n        };\n          console.log(findElement(arr, \"hello\"));\n\n          console.log(findElement(arr, 3));\n\n          console.log(arr.includes(\"hello\"));\n\n2.  How do check if an element exits or not if exits return its index\n\n          const findElementIndex =    (arr,target)=\u003e{\n            for(let i=0;i\u003carr.length;i++){\n                if(arr[i] === target){\n                    return i;\n                }\n            }\n            return -1;\n        }\n        console.log(findElementIndex(arr,3));\n        console.log(arr.indexOf(2));\n\n3.  How to delete, add \u0026 Update element from specific index\n\n            arr.splice(1,3);  // delete 3 items from 1 index\n\n        console.log(arr);\n\n        arr.splice(1, 0, 10, 20, 30); // add items from 1 index\n\n        arr.splice(1,3,10,20,30,40);\n\n        let subArr = arr.slice(1,3);   //slice or break arr into subarray\n\n4.  how to add two array\n\n          const newArr = [...arr, ...arrE];\n\n          console.log(newArr);\n\n          const arr = [1, 2, 3, 4, \"hello\"];\n\n5.  how to check if two arrays are equal\n\n        const isArrayEqual=(arr1,arr2)=\u003e{\n        if(arr1.length !== arr2.length){\n            return false;\n        }\n\n        for(let i=0;i\u003carr1.length;i++){\n            if(arr1[i] !== arr2[i]){\n                return false;\n            }\n        }\n\n        // return true;\n\n        return arr1.length === arr2.length \u0026\u0026 arr1.every((ele,i)=\u003e arr1[i] === arr2[i])\n\n        }\n\n        const arr = [1, 2, 3, 4, \"hello\"];\n\n        const arr2 = [1,2,3,4,'hello'];\n\n        console.log(isArrayEqual(arr,arr2));\n\n6.  how to sort an array in ascending and desending order\n\n        let arr =[1,4,6,0,-9,-5];\n\n        arr.sort();\n\n        console.log(arr);\n\n7.  How to reverse array\n\n          let arr = [1,4,6,0,-9,-5];\n\n          arr.reverse();\n          let newArr = [];\n\n        for (let i = arr.length - 1; i \u003e= 0; i--) {\n          newArr.push(arr[i]);\n        }\n\n        console.log(newArr);\n\n8.  filter vs find\n\n// find method return first element when condition satisfies\n\n// filter check for revery element and return all elements which satisfy the condition\n\n        const numbers = [1, 2, 3, 4, 5];\n\n      // const evenNumbers = numbers.filter((number) =\u003e number % 2 === 0);\n\n    const evenNumbers = numbers.find((number) =\u003e number % 2 === 0);\n    console.log(evenNumbers); // return first element which statis condiiton\n\n### About For Loop\n\nLearning - You don't Know FOR LOOP yet! : 😁\n\n-In JavaScript, the code is executed in two phases:\n\n- Memory Creation Phase. ⚡\n- Code Execution Phase. ⚡\n\n- About for loop - The for statement creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement (usually a block statement) to be executed in the loop. (Mozilla) docs about JS For Loop.\n\nExamples:\n\n          for(let i=0;i\u003c3;i++){\n          console.log(i); // 0 1 2\n          }\n\n          for(var i=0;i\u003c3;i++){\n          console.log(i); // 0 1 2\n          }\n\n- var - global scope\n- let - block scope.\n- with setTimeOut\n\n      for(let i=0;i\u003c3;i++){\n      setTimeout(()=\u003e{\n      console.log(i); // 0 1 2\n      },1000);\n      }\n\n  for (var i = 0; i \u003c=3; i++) {\n  setTimeout(() =\u003e {\n  console.log(i); // 4 - (4) times\n  }, 1000);\n  }\n\n- SetTimeout basically goes inside WEB API (call back Queue) of Browser.\n\n- Lexical Declaration cannot appear in a single statement context.\n\n- The only thing is read MDN DOCS For knowing all about for loop.\n\n- In Docs, all aspects will be cover and given examples.\n\n- Examples:\n\n        for(let i=0;getI=()=\u003ei, i\u003c3;i++){\n        console.log(getI());\n        }\n\n- Declaring a variable within the initialization block has important differences from declaring it in the upper scope, especially when creating a closure within the loop body.\n\n- new lexical scope is created with new block level (let \u0026 const both).\n\n- new block is created every time .when it executes loop.\n\n- new block created for every value\n\n       for(let i=0 ;i\u003c3;i++){\n       setTimeout(()=\u003econsole.log(i)); // 0 1 2\n       }\n\n### JS objects\n\nObject is a collection of properties \u0026 methods.\n\n- Key-value pair\n\n        let user = {\n          name:\"Lucky\",\n          age:22,\n      };\n\n- We can add \u0026 remove property in object.\n- we use of for in loop to iterate over every value.\n\nObject is most Important in JS.\n\nEverything in JavaScript is Derived From the Objects.\n\n### Logical Based Questions\n\n1 - Given a string, reverse each word in the sentence\n\n      let str = \"Harsh bhai kese ho\";\n\n    let res = str.split(' ').map(function(word){\n        return word.split('').reverse().join('')\n    });\n\n    console.log(res.join(' '));\n    console.log(res);\n\n    function reverse(str){\n    let rev = '';\n\n    rev = str.split('').reverse().join('');\n\n    // rev.reverse();\n\n    // rev.join(\"\");\n\n    return rev;\n    }\n    let res = reverse(str);\n\n    console.log(res);\n\n2 - how to check if an object is an array or not\n\n    function checkArr(el){\n    let check = Array.isArray(el);\n\n    console.log(check);\n\n      }\n\n      checkArr([]);\n      checkArr({});\n\n3- how to empty an array\n\n    function empty(arr) {\n      arr.length = 0;\n\n      return arr;\n\n    arr=[];\n\n    return arr;\n    return [];\n    }\n\n    console.log(empty([2, 3, 4, 5, 6, 2, 3]));\n\n4 - how would you check if an number is an integer\n\n    function checkInteger(a){\n        return Number.isInteger(a);\n    }\n\n    console.log(checkInteger(''));\n\n    let a = 15;\n\n    console.log(a%1);   // 0\n    if(a%1===0){\n        console.log('Integer');\n    }\n    else{\n        console.log('Not an Integer');\n    }\n\n5- make this work  \nduplicate ([1,2,3,4,5]); [1,2,3,4,5,1,2,3,4,5]\n\n    function duplicate(arr){\n        return arr.concat(arr);\n    }\n\n    let arr = [1,2,3,4,5];\n\n    let res = duplicate(arr);\n\n    console.log(res);\n\n6 - reverse number\n\n    function reverseNumber(num){\n\n        let rev=0;\n        // console.log(num%10);\n        let temp = num;\n        while(temp!=0){\n            let rem = temp % 10;\n            rev = rev*10 + rem;\n            // num =num\u003c\u003c1;\n            temp=Math.floor(temp/10);\n        }\n\n        return rev;\n    }\n\n    function reverseNumber(num){\n        return Number(num.toString().split('').reverse().join(''));\n    }\n\n    let num = 123544;\n\n    let res = reverseNumber(num);\n\n    console.log(res);\n\n7- string is palindrome or not\n\n    function isPalindrome(str) {\n    let rev = str.split(\"\").reverse().join(\"\");\n\n      if (rev === str) {\n        return true;\n      } else {\n        return false;\n      }\n    }\n\n    let str = \"rahul\";\n\n    let res = isPalindrome(str);\n\n    console.log(res);\n\n8 - write a javascript function that returns a passed string with letters in\n// alphabetical order\n\n    function alphabeticalOrder(str){\n        return str.split('').sort().join(\"\");\n    }\n\n    let str ='divyanshukashyap';\n\n    let res = alphabeticalOrder(str);\n\n    console.log(res);\n\n9- Write a Javascript function that accepts a string as a parameter\n//and converts the first letter of each word of the string in uppercase\n\n    let str = \"hello how are You..\";\n\n    function firstUpper(str) {\n      let upper = str.split(\" \").map(word=\u003e word.charAt(0).toUpperCase() + word.substring(1));\n\n    let res = upper.charAt(0).toUpperCase() + upper.substring(1);\n\n    for (let i = 0; i \u003c upper.length; i++) {\n      // upper.charAt(i).toUpperCase();\n      upper = upper[i].charAt(i).toUpperCase() + upper.substring(1)\n    }\n\n      return upper.join(' ');\n    }\n\n    let res = firstUpper(str);\n\n    console.log(res);\n\n10- find targeted element\n\n    let arr = [10, 20, 30, 40, 50, 60];\n\n    function findTarget(target, arr) {\n      let start = 0;\n      let end = arr.length;\n      let mid = start + (end -start) / 2;\n      let res = false;\n\n      for (let i = 0; i \u003c arr.length; i++) {\n        if (arr[i] == target) {\n          res = true;\n        } else if (arr[mid] \u003c target) {\n          end = mid - 1;\n        } else {\n          start = mid + 1;\n        }\n        mid =start + (end -start) / 2;\n      }\n    console.log(start,end);\n      return res;\n    }\n\n    let target = 100;\n\n    let res = findTarget(target, arr);\n\n    console.log(res);\n\n11 - write a js function to get the number of occurrences of each letter in specified string\n\n// apple = a - 1 p - 2 l - 1 e - 1\n\n    let str = \"hello i am lucky\";\n\n    function findOccurences(str) {\n    let count = [];\n      let occ = {};\n\n      str.split(\"\").forEach((char) =\u003e {\n        if (occ.hasOwnProperty(char) === false) {\n          occ[char] = 1;\n        } else {\n          occ[char]++;\n        }\n      });\n\n    for(let i=0;i\u003cstr.length;i++){\n      for(let j=1;j\u003cstr.length;j++){\n        if(str[i]==str[j]){\n            count++;\n\n        }\n      }\n    }\n      return occ;\n    }\n\n    let res = findOccurences(str);\n\n    console.log(res);\n\n12- loop an array and add all members of it\n\n    let arr = [1,2,3,4,5,6];\n\n    function addAll(arr){\n      let sum = 0;\n\n      for(let i=0;i\u003carr.length;i++){\n        sum +=arr[i];\n      }\n\n      return sum;\n    }\n\n    let res = addAll(arr);\n\n    console.log(res);\n\n    var arr = [1, 2, 3, 4, 5, 6];\n\n    let sum = 0;\n\n    arr.forEach((num) =\u003e (sum += num));\n\n    console.log(sum);\n\n13 - in an array of numbers and strings, only add\n// those members which are not strings\n\n    let arr =['Hello',123,\"jhbvh \",\"hjb u\",\"hjgbuyhj\",3,4,'ugvyug'];\n\n    let sum = 0;\n\n    arr.forEach(char=\u003e{\n    if(typeof char === 'number'){\n    sum += char;\n    }\n    });\n\n    console.log(sum);\n\n14 - loop an array of objects and remove all objects\n// which don't have gender's value male\n\n    let arr = [\n    {\n    name: \"lucky\",\n    gender: \"male\",\n    },\n    {\n    name: \"harsh\",\n    gender: \"female\",\n    },\n    {\n    name: \"arun\",\n    gender: \"non\",\n    },\n    {\n    name: \"mukul\",\n    gender: \"others\",\n    },\n    {\n    name: \"lucky\",\n    gender: \"female\",\n    },\n    ];\n\n    let newArr = arr.filter(char=\u003e char.gender === 'male');\n\n    console.log(newArr);\n\n15 - sbase pehle total non-male count lo\n// ek non male bande ko hataane ka code likho\n// fir us code ko total non-male chla do\n\n      let count = 0;\n\n      arr.forEach((char) =\u003e {\n      if (char.gender !== \"male\") count++;\n      });\n\n      console.log(count);\n\n      for (let i = 1; i \u003c= count; i++) {\n      for (let j = 0; j \u003c arr.length; j++) {\n      if (arr[j].gender !== \"male\") {\n      arr.splice(j, 1);\n      }\n      }\n      }\n\n      console.log(arr);\n\n16 - write a js function to clone an array\n\n    function cloneArr(arr) {\n    return [...arr];\n\n    let newArr = [];\n\n    arr.forEach((el) =\u003e newArr.push(el));\n\n    return newArr;\n\n    return arr.map((char) =\u003e char);\n    }\n\n    let arr = [1, 2, 3, 4, 5];\n\n    let res = cloneArr(arr);\n\n    console.log(arr, res);\n\n17 - write a js function which accepts an argument \u0026 returns the type\n// Note : there are six possible values that typeof returns : object, boolean, function, number , string \u0026 undefined\n\n    function typeTeller(arg){\n    return typeof arg;\n    }\n\n    console.log(typeof typeTeller);\n\n    // console.log(typeTeller([]));\n    // console.log(typeTeller('lucky'));\n    // console.log(typeTeller(null));\n    // console.log(typeTeller({}));\n    // console.log(typeTeller(true));\n    // console.log(typeTeller(10));\n\n18 - write a js function to get the first element of an array. Passing a paramter 'n' will return the first 'n' elements of the array.\n\n    function retreive(arr = [], n = 1) {\n    console.log(arr);\n    let newArr = [];\n\n    if(n\u003c=arr.length){\n    for (let i = 0; i \u003c n; i++) {\n    newArr.push(arr[i]);\n    }\n    }\n    else{\n    console.log('limit exceded');\n    }\n\n    for (let i = 0; i \u003c n; i++) {\n    newArr.push(arr[i]);\n    }\n\n    return newArr;\n    }\n\n    let arr = [1, 2, 3, 4, 5];\n\n    let res = retreive(arr,4);\n\n    console.log(res);\n\n19 - write a js function to get the last element of an array. Passing a parameter 'n' will return the last 'n' elements of the array\n\n    function retreive(arr=[],n=1){\n\n    if(n\u003c=arr.length){\n    for(let i=0;i\u003cn;i++){\n    console.log(arr[arr.length - 1 - i]);\n    }\n    }\n    else{\n    console.log('limit exceeded');\n    }\n    }\n\n    let arr = [1,2,3,4,5,6];\n\n    let res = retreive(arr,3);\n\n    console.log(res);\n\n20 - write a js program to find the most frequent item of an array\n\n    function freq(arr){\n    let freq= {};\n\n    arr.forEach(char=\u003e{\n    if(freq.hasOwnProperty(char)) freq[char]++;\n    else freq[char] = 1;\n    });\n\n    console.log(Object.keys(freq));\n\n    let ans = Object.keys(freq).reduce((acc,num)=\u003e{\n    return freq[acc] \u003e freq[num] ? acc : num;\n    })\n    console.log(ans);\n    for(let i=0;i\u003carr.length;i++){\n    for(let j=1;j\u003carr.length;j++){\n    if(arr[i]==arr[j]){\n    count++;\n    }\n    }\n    }\n    }\n\n    let arr = [1,2,3,12,2,3,12,1,2,3,2121];\n\n    freq(arr);\n\n21 - write a js program to shuffle an\n// array\n\n// [1,2,3,4,5,6,7] = \u003e [2,4,5,1,3,6];\n\n    function shuffleArr(arr){\n    let totalShuffleArea = arr.length;\n\n    while(totalShuffleArea\u003e0){\n    totalShuffleArea--;\n    let indexToBeExchanged = Math.floor(Math.random() \\* totalShuffleArea);\n\n    let temp = arr[totalShuffleArea];\n    arr[totalShuffleArea] = arr[indexToBeExchanged];\n    arr[indexToBeExchanged] = temp;\n    }\n\n    return arr;\n    }\n\n    let arr = [1,2,3,4,5,6];\n\n    let res = shuffleArr(arr);\n\n    console.log(res);\n\n22 - write a js program to compute the union\n// of two arrays\n\n    function unionArr(arr1, arr2) {\n    return [...new Set(arr1.concat(arr2))];\n    }\n\n    let arr1 = [1, 2, 3, 4];\n    let arr2 = [2, 3, 4, 6666];\n\n    let res = unionArr(arr1, arr2);\n\n    console.log(res);\n\n    // count words\n\n    function countWord(str) {\n    let character = str.length;\n\n    let wordLength = str.trim().split(\" \").length;\n\n    console.log(\"Character length \", character);\n\n    return wordLength;\n    }\n\n    let str = \"React JS Developer from India\";\n\n    let res = countWord(str);\n\n    console.log(\"Word Count : \" + res);\n\n### use strict\n\n- varible declaration\n\n         \"use strict\";\n\n          a = 12;\n\n          console.log(a);\n\n- can't delete the variable\n\n        \"use strict\";\n\n        var a = 12;\n\n        a = 20;\n\n        delete a;\n\n- can't make same parameters in functions\n\n      // b ki value overwrite ho rhi hai\n\n      'use strict'\n\n      function calculator(a, b, b) {\n\n        return a + b + b;\n      }\n\n      let res = calculator(12, 2, 3);\n\n      console.log(res);\n\n      \"use strict\";\n\n      function calculator(a, b, b) {\n        return a + b;\n      }\n\n      let res = calculator(12, 2, 3);\n\n      console.log(res);\n\n### Recursion\n\nprint fun n times\n\n      function fun(n){\n        if(n==0){\n          return ;\n        }\n\n        console.log('fun',n);\n\n      }\n\n      fun(10);\n\nprint factorial\n\n        function fact(n){\n\n          if(n==0 || n==1){\n\n            return 1;\n          }\n          else{\n            return n*fact(n-1);\n          }\n        }\n\n        let res = fact(5);\n\n        console.log(res);\n\n### Map vs Filter vs Reduce\n\n- they are basically array methods\n- that are used to iterate over an array\n- and perform transformation or computation\n- each may return or not\n\n      const nums = [1,2,3,4,5];\n\n      // callback num,i,nums  -\u003e element , index, array\n\n      const multiplyThree = nums.map(num=\u003enum*3);\n\n      console.log(multiplyThree);\n\n# filter\n\n    const nums = [1,2,3,4,12,1,5];\n\n    const moreThanTwo = nums.filter(num =\u003e num\u003e2);\n\n    console.log(moreThanTwo);\n\n# reduce\n\n    const nums = [1, 2, 3, 4, 5];\n\n- by default acc = 0 acc,curr,i,arr\n- acc result of previous value\n\n- if there is no initial value, it takes\n- first element of array as value for\n- accumulator\n\n      const sum = nums.reduce((acc, num,i,arr) =\u003e {\n      return acc + num;\n      });\n\n      console.log(sum);\n\n# Write polyfill\n\n    const nums = [1,2,3,4,5];\n\n    function mapPoyfill(callback,nums){\n    let arr=[];\n    for(let i=0;i\u003cnums.length;i++){\n    arr.push(callback(nums[i]));\n    }\n\n    return arr;\n\n    }\n\n    function multiplyThree(num){\n    return num\\*3;\n    }\n\n    const newArr = mapPoyfill(multiplyThree,nums);\n\n    console.log(newArr);\n\n\n\n        const nums = [1,2,3,4,5];\n\n        Array.map((num,i,arr)=\u003e{\n\n        });\n\n        Array.prototype.myMap = function(callback){\n        let temp = [];\n\n        for(let i=0;i\u003cthis.length;i++){\n          temp.push(callback(this[i],i,this));\n        }\n\n        return temp;\n        }\n\n        const multiplyThree = nums.myMap((num,i,arr)=\u003e{\n        return num \\* 3;\n        });\n\n        console.log(multiplyThree);\n\n# filter polyfill\n\n    const nums = [1, 2,12, 3, 4, 5];\n\n    function filterPoyfill(callback, nums) {\n    const newArr = [];\n\n    for (let i = 0; i \u003c nums.length; i++) {\n    newArr.push(callback(nums[i]));\n    if (callback(nums[i])) {\n    newArr.push(nums[i]);\n    }\n    }\n\n    return newArr;\n    }\n\n    function moreThanTwo(num) {\n    return num \u003e 2;\n    }\n\n    const filterThanTwo = filterPoyfill(moreThanTwo, nums);\n\n    console.log(filterThanTwo);\n\n    const nums = [1, 2, 3, 4, 5];\n\n    Array.prototype.myFilter = function (callback) {\n    let temp = [];\n\n    for (let i = 0; i \u003c this.length; i++) {\n    if (callback(this[i], i, this)) {\n    temp.push(this[i]);\n    }\n    }\n    return temp;\n    };\n\n    const moreThanTwo = nums.myFilter((num) =\u003e num \u003e 2);\n\n    console.log(moreThanTwo);\n\n# reduce polyfill\n\n    const nums = [1, 2, 3, 4, 5];\n\n    Array.prototype.myReduce = function (callback) {\n    let temp=0;\n\n    for (let i = 0; i \u003c this.length; i++) {\n    temp += callback(0,this[i]);\n    }\n    return temp;\n    };\n\n    const sum = nums.myReduce((acc, num) =\u003e acc + num);\n\n    console.log(sum);\n\n    Array.prototype.myReduce = function (cb, initialValue) {\n    let accumulator = initialValue;\n\n    for (let i = 0; i \u003c this.length; i++) {\n    accumulator = accumulator ? cb(accumulator, this[i], i, this) : this[i]; }\n\n    return accumulator;\n    };\n\n    const nums = [1,2,3,4,5,6];\n\n    const result = nums.myReduce((acc,num)=\u003e{\n    return acc += num;\n    },10);\n\n    console.log(result);\n\n# map vs forEach\n\n    const arr = [2, 5, 3, 6];\n\n    const newArr = arr.map((num) =\u003e num + 2);\n\n    const newForEachArr = arr.forEach((num, i) =\u003e {\n    arr[i] = num + 4;\n    });\n\n    console.log(newArr);\n\n    console.log(arr);\n    console.log(newForEachArr);\n\n# Return only name of students in Capital\n\n    let students = [\n    {\n    name: \"Lucky\",\n    rollNumber: 31,\n    marks: 80,\n    },\n    {\n    name: \"Jenny\",\n    rollNumber: 15,\n    marks: 79,\n    },\n    {\n    name: \"Kaushal\",\n    rollNumber: 16,\n    marks: 35,\n    },\n    {\n    name: \"Dilpreet\",\n    rollNumber: 7,\n    marks: 85,\n    },\n    {\n    name: \"aushal\",\n    rollNumber: 16,\n    marks: 85,\n    },\n    {\n    name: \"Dilpreet\",\n    rollNumber: 7,\n    marks: 69,\n    },\n    ];\n\n    let names = [];\n\n    for(let i=0;i\u003cstudents.length;i++){\n    names.push(students[i].name.toUpperCase());\n    }\n\n    console.log(names);\n\n    const filterName = students.filter((st)=\u003e st.name);\n\n    const filterName = students\n    .map((st) =\u003e st.name)\n    .filter((name) =\u003e {\n    return name.toUpperCase();\n    });\n\n    console.log(filterName);\n\n    const capitalName = students\n    .map((st) =\u003e st.name.toUpperCase())\n\n    console.log(capitalName);\n\n# return only details of those who scored more than 60 marks\n\n    const score = students.filter(st=\u003est.marks\u003e60);\n\n    const score = students.map((st) =\u003e st.marks).filter((marks) =\u003e marks \u003e 60);\n\n    console.log(score);\n\n    // more than 60 marks \u0026 rollNumber greater than 15\n\n    const score = students.filter(st=\u003est.marks\u003e60 \u0026\u0026 st.rollNumber\u003e15);\n\n    console.log(score);\n\n    const sumOfMarks = students.map(st=\u003est.marks).reduce((acc,st)=\u003e{\n    return acc += st;\n    });\n\n    console.log(sumOfMarks);\n\n# return only names of students who scored more than 60\n\n    const nameScore = students.filter(st=\u003e st.marks\u003e60 ).map(st=\u003est.name);\n\n    console.log(nameScore);\n\n# return total marks for students with marks greater than 60 after 20\n\n// marks have been added to those who scored less than 60\n\n    const totalMarks = students\n    .map((st) =\u003e {\n    if (st.marks \u003c 60) {\n    st.marks += 20;\n    }\n\n        return st;\n\n    })\n    .filter((st) =\u003e st.marks \u003e 60)\n    .reduce((acc, curr) =\u003e acc + curr.marks, 0);\n\n    console.log(totalMarks);\n\n# Async vs Sync JS\n\n- Basically how JS code excutes \u0026 run async code\n- promise, setTimeout , async, await\n\nFor asynchronous Code :\n\n- we write code in promise, setTimeout, async, await\n\n- Javascript Engine Working\n- Javascript Call Stacks\n- Javascript Browser WebAPI's\n- Javascript Task Queue and Micro Task Queue\n- Working with Javascript Promises and Timers\n\n- Javascript Task Queue and Micro Task Queue\n- Async Javascript and Event Loop\n\n       function a() {\n         console.log(\"A\");\n       }\n\n       setTimeout(() =\u003e {\n         console.log(\"B\");\n       }, 0);\n\n       a();\n\n       console.log(\"C\");\n\n       Promise.resolve().then(() =\u003e console.log(\"D\"));\n\n       async function getData() {\n         return 1;\n       }\n\nExample 2:\n\n      console.log(\"A\");\n\n      console.log(\"B\");\n\n      setTimeout(() =\u003e console.log(\"C\"), 0);\n\n      getData().then(() =\u003e console.log(\"I got the data\"));\n\n      console.log(\"D\");\n\n      console.log(\"E\");\n\n      console.log(\"F\");\n\n# Hamburger Menu\n\nUsing HTML, CSS \u0026 JS\n\n![ezgif com-video-to-gif (1)](https://github.com/Lucky-Kashyap/JS-interview-practice/assets/88204554/014cdcc6-c39e-457f-983e-5434658c63b7)\n\n# Problem Based on map vs filter vs reduce\n\n1. Convert array\n\nInput: const arr = [1,2,3,58,5,6,24,8,15,4];\n\nOutput : [1,3,3,59,5,7,25,9,15,5]\n\n    function convertArr(arr) {\n      let newArr = [];\n\n    for (let i = 0; i \u003c arr.length; i++) {\n      if (arr[i] % 2 == 0) {\n        arr[i] += 1;\n\n    newArr.push(arr[i]);\n      }\n    }\n\n      newArr = arr.map((el) =\u003e (el % 2 == 0 ? (el += 1) : el));\n\n      return newArr;\n    }\n\n    const arr = [1, 2, 3, 58, 5, 6, 24, 8, 15, 4];\n\n    let res = convertArr(arr);\n\n    console.log(res);\n\n2 - Given an array of objects. Write a function to find the sum of ages of each person.\n\n    const arr = [\n      {\n        name: \"jay\",\n        age: 60,\n      },\n      {\n        name: \"Gloria\",\n        age: 36,\n      },\n      {\n        name: \"Maddy\",\n        age: 16,\n      },\n      {\n        name: \"Joe\",\n        age: 9,\n      },\n    ];\n\n    // output  121 // 60 + 36 + 16 + 9\n\n    console.log(arr.map((el) =\u003e (el.age += el.age)));\n\n    console.log(arr.map((el) =\u003e el.age).reduce((acc, curr) =\u003e (acc += curr)));\n\n3 - Given array of object \u0026 find this :\n\nOutput: ['Tanay','Tanvi'];\n\n    const family = [\n      {\n        name: \"Tanay\",\n        haveCycle: true,\n      },\n      {\n        name: \"Akansha\",\n        haveCycle: false,\n      },\n      {\n        name: \"Tanvi\",\n        haveCycle: true,\n      },\n      {\n        name: \"Kanak\",\n        haveCycle: false,\n      },\n    ];\n\n\n\n    console.log(\n      family.filter((name) =\u003e name.haveCycle == true).map((name) =\u003e name.name)\n    );\n\n    console.log(family.map((el) =\u003e el.haveCycle === true).filter((name) =\u003e name));\n\n    console.log(family);\n\n4 - Given an array. Write a function that takes in the given array and prints only the numbers which are less than 8 and also an even number\n\nOutput: [2,6,8,4]\n\n    const arr = [1, 2, 3, 58, 5, 6, 24, 8, 15, 4];\n\n    console.log(arr.filter((el) =\u003e el % 2 == 0 \u0026\u0026 el \u003c= 8));\n\n5 - Given an array. Write a function that takes in the given array and prints only the words which are more than 5 characters in length.\n\nYour output should be : ['repeat']\n\n    const arr = [\"eat\", \"sleep\", \"repeat\", \"code\"];\n\n    console.log(arr.filter((el) =\u003e el.length \u003e 5));\n\n6 - Given an array. Write a function to get the sum of all elements which are greater than 50.\n\nYour output should be: 190\n\n    const arr = [1, 2, 3, 58, 5, 62, 6, 8, 70];\n\n\n\n    console.log(arr.reduce((acc, cur) =\u003e (acc += cur \u003e 50)));\n\n    console.log(arr.filter((el) =\u003e el \u003e 50).reduce((acc, curr) =\u003e (acc += curr)));\n\n7 - Given an array. Write a function to find the product of all elements which are even.\n\nYour output should be: 96\n\n      const arr = [1, 2, 3, 7, 5, 6, 8, 9];\n\n\n\n      console.log(\n        arr.filter((el) =\u003e el % 2 == 0).reduce((acc, curr) =\u003e (acc *= curr))\n      );\n\n8 - Given an array. Convert it in to an object with key as the index of each element and value as the element itself.\n\nOutput : {'0':'you','1':'all','2':'are','3':'rockstars'};\n\n    function convertIntoObj(arr) {\n      let obj = {};\n\n      for (let i = 0; i \u003c arr.length; i++) {\n        obj[i] = arr[i];\n      }\n\n      return obj;\n    }\n\n    let res = convertIntoObj(arr);\n\n    console.log(res);\n\n    console.log(arr.reduce((acc, curr, index) =\u003e ({ ...acc, [index]: curr }), {}));\n\n9 - Given an array. Write a function to join all elements of the array with a hyphen in between them\n\nOutput: Violet-Indigo-Blue-Green-Yellow-Orange-Red\n\n    function addArrow(arr) {\n    for (let i = 0; i \u003c arr.length; i++) {\n      arr[i] += \"-\";\n    }\n\n      return arr.join(\"-\");\n    }\n\n    let res = addArrow(arr);\n\n    console.log(res);\n\n    const arr = \"Violet\";\n\n    console.log([...arr].join(\"-\"));\n\n10 - Flatten an array without using flat()\n\n    const input = [\n      [\"a\", \"b\", \"c\"],\n      [\"c\", \"d\", \"e\"],\n      [\"e\", \"d\", \"f\"],\n    ];\n\n    const flatArr = [...input];\n\n    const flatArr = input.reduce((acc, curr) =\u003e [...acc, ...curr], []);\n\n    console.log(flatArr);\n\n### Scenario Based Questions\n\n- How to validate user input as they type in a form\n\n- How to implement pagination for displaying large sets of data?\n\n- How to store key-value pairs \u0026 efficiently access and manipulate the data?\n\n- How to implement drag-and-drop functionality for elements on a webpage?\n\n- How to iterate over elements in an array and perform a specific operation on each element?\n\n- How to implement a feature that allows users to search for specific items in a large dataset?\n\n- How to implement a feature that allows users to perform live search suggestions as they type?\n\n# 100 Days of JavaScript Coding Challenges\n\n## Day 1\n\n#### Write a function to find longest word that takes a string as input and returns the longest word in the string. If there are multiple longest words, return the first one encountered.\n\n- Constraints\n\n  - The input string may contain alphabetic characters, digits, spaces, and punctuation.\n\n  - The input string is non-empty.\n\n  - The input string may contain multiple words seperated by spaces\n\n- Note\n\n  - If the input strng is empty or contains only whitespace, the function should return an false.\n\n  - The function should ignore leading and trailing whitespace when determining the longest word.\n\n- sort method sort values in unicode value . first letter in a ascending order\n\n- a\u003eb 1 b\u003ea -1\n\n## Day 2\n\n#### Programming Question: HAsh Tag Generator\n\n- You are required to implement a function generateHAsh that generates a hash tag from a given input string.\n\n- The hash tag should be constructed as follows:\n\n- The input string should be converted to a hash tag format, where each word is capitalized and concatenated together without spaces.\n\n- If the length of the input string is greater then 280 characters or if the input string is empty or contains only whitespaces, the function should return false.\n\n- Otherwise the function should return the generated hash tag prefixed with #.\n\n- write a function generateHAsh to accomplish this task\n\n- generatehash\n  - input str = 'my name is lucky kashyap';\n  - output #MyNameIsLuckyKashyap\n\n## Day 3\n\n#### Programming Question: Count Occurrences of Character\n\n- Write a function called countChar tht takes two parameters: a string and a character to count. The function should return the number of times the specified character appears in the string.\n\n- Input : console.log(countChar(\"MissIssippi\",\"I\")) // output : 4\n\n- Note:\n  - The function should be case-senstive\n  - The function should handle both lowercase and uppercase characters\n  - The character parameter can be any printable ASCII character (the function should accept any character that is part of the ASCII character set and is printable).\n\n## Day 4\n\n#### Coding Challenge: Check Triangle\n\n- Write a function called checkTriangleType that takes three parameters representing the lengths of the sides of a triangle. The function should return a string indicating the type of triangle: \"equilateral\", \"isosceles\", or \"scalene\"\n\n- 3 3 3 \"equilateral\"\n- 3 4 3 \"isosceles\"\n- 5 8 6 \"scalene\"\n\n- Todo The Function should adhere to the following rules:\n\n  - If all three sides are of equal length, return \"equilateral\"\n  - If only two sides are of equal length, return \"isosceles\"\n  - If all three sides have different lengths, return \"scalene\"\n\n## Day 5\n\n#### Write a function to sort an array of numbers in an ascending order.\n\n- Note:\n\n  - The function should take an array of numbers as input.\n  - It should return a new array with the numbers sorted in ascending order.\n  - The original array should remain unchanged.\n  - You are not allowed to use the built-in sort() method.\n\n## Day 6\n\n#### Write a function to determine whether a given string is a palindrome or not. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, ignoring spaces, punctuation, and capitalization.\n\n- Note:\n\n  - The input string may contain letters, digits, spaces, punctuation, and special characters.\n\n  - The function should be case-insensitive, meaning \"Racecar\" and \"racecar\" should be considered the same.\n\n  - Ignore spaces, punctuation, and special characters when determining if a string is a palindrome.\n\n  - The function should return true if the input string is a palindrome and false otherwise.\n\n  - .replace(/\\W/g,''); Uses the replace() method with a regular ecpression (/\\W/g) to remove ll non-word characters from the string. Here:\n\n  - \\W matches any non-word character (equivalent to [^a-zA-Z0-9_]).\n\n  - The g flag performs a global search, meaning it replaces all occurrences of non-word characters in the string.\n\n  - So, replace(/\\W/g,'') replaces all non-word characters with an empty string, effectively removing them from the string.\n\n## day 7\n\n#### Write a function findMax that takes an array of numbers as input nd returns the maximum number in the array.\n\n## Day 8\n\n### Challenge: Factorial Finder\n\n#### Write a function factorial that takes a non-negative integer num as input and returns its factorial. The factorial of a non-negative integer n, denoted as n!, is the product of all positive integers less than or equal to n. The factorial of 0 is defined as 1.\n\n- Here are some examples of factorial calculations:\n\n  - factorial(0) =\u003e 1\n  - factorial(1) =\u003e 1\n  - factorial(2) =\u003e 2\n  - factorial(3) =\u003e 6\n  - factorial(4) =\u003e 24\n  - factorial(5) =\u003e 120\n\n- Your function should work for any non-negative integer\n\n## Day 9\n\n### Challenge: Calculate the Average\n\n#### Write a function called calculateAverage that takes an array of numbers as input and returns the average of those numbers.\n\n##### Your function should:\n\n- Accept an array of numbers as input.\n\n- Calculate the sum of all the numbers in the array.\n\n- Divide the sum by total number of elements in the array to find the average.\n\n- Return the calculated average.\n\n- Note:\n\n  - Ensure the function handles arrays of any length.\n  - The average should be returned as a floating-point-number.\n\n## day 10\n\n#### Write a function arraysAreEqual that takes two arrays arr1 and arr2 as input and returns true if the arrays are equal (i.e., contains the same elements in the same order), and false otherwise.\n\n- Note:\n\n  - The function should return false if the arrays have different lengths.\n  - The function should compare each element of arr1 with the corresponding element in arr2.\n  - The function should return true only if all elements in arr1 are equal to their corresponding elements in arr2.\n\n## Day 11\n\n#### Write a function that takes a number as input and returns the sum of its digits.\n\n- Note:\n\n  - The input number will always be a positive integer.\n\n  - The input number can have multiple digits.\n\n  - The output should be the sum of all the digits in the input number.\n\n  - This function calculates the sum of digits without converting the number to a string.\n\n## Day 12\n\n#### Write a function that takes an array of integers as input and removes any duplicate elements, returning a new array with only the unique elements.\n\n- The new Set() method in JavaScript creates a new Set object. A Set object is a collection of unique values. It can store any type of value, whether primitive values or object references.\n\n- Note:\n\n  - The input array may contain both positive and negative integers.\n\n  - The input array may be empty.\n\n  - The elements in the input array are not guranteed to be sorted.\n  - The output array should retain the original order of elements from the input array\n\n## Day 13\n\n#### Write a function that takes a string as input and returns the count of vowels in that string. Consider 'a', 'e', 'i', 'o' and 'u' as vowels (both lowercase and uppercase)\n\n- Note:\n\n  - The input string may contain letters in both uppercase and lowercase.\n\n  - The output should be a non-negative intger representing the count of vowels in the input string.\n\n## Day 14\n\n#### Write a function called isPowerOfTwo that takes an integer num as input and returns true if num is a power of two, and false otherwise.\n\n- Note:\n\n  - The input num will be a positive integer\n    Zero (0) and negative integers are not considered powers of two.\n\n  - The function should return true if the given number is a power of 2, and false otherwise.\n\n## Day 15\n\n#### Write a function to calculate the sum of squares of al elements in an array. For example, given the array [1,2,3], the function should return 14 because 1*1 + 2*2 + 3\\*3 = 1+4 + 9 = 14\n\n## Day 16\n\n#### Write a function findMin that takes an array of numbers as input and returns the minimum value found in the array.Find the Minimum Value in an Array\n\n- Note:\n\n  - The input array may contain both positive and negative integers\n  - The input array may be empty\n  - The input array may container duplicate values\n\n- Ensure the function handles edge cases gracefully, such as an empty input array.\n\n- Consider using ES6 features like the spread syntax (...) for a concise implementation.\n\n- Todo In JavaScript, the spread syntax (...) is used to expand\n  an array into individual elements. In this function, ...arr is used to spread the elements of the input array arr.\n\n## Day 17\n\n#### Write a function to convert a string to camelCase \u0026 snake_case.\n\n- slice() extracts a part of a string and returns the extracted part ina new String.\n\n  - JS counts positions from zero.\n  - slice() extracts up to but not includding indexEnd.\n\n## Day 18\n\n#### Write a function to chek if a character is uppercase or lowercase.\n\n- Constraints:\n\n  - The input char will be a single character.\n  - The character can be any printable ASCII character.\n  - You can assume that the input will always be a string of length 1.\n\n- Note:\n\n  - Ensure that the function correctly identifies uppercase characters based on their ASCII values.\n  - Optimize the function to handle edge cases efficiently.\n\n## Day 19\n\n#### Write a function to check if a given string starts with a specific substring.\n\n- str: A string (e.g. \"Hello world\").\n\n- subStr: A substring to check if it starts the given string(e.g. \"Hello\").\n\n- Output: true if the given string starts with the specified substring, otherwise false\n\n## Day 20\n\n#### Write a function to reverse a string without using any built-in method or libraries.The function should take a string as input and return the reversed string.\n\n## Day 21\n\n#### Write a function called calculateMean that takes an array of numbers as input and returns the mean (average) of those numbers.\n\n- Note :\n\n  - In math, the mean is the average of a set of numbers, or the numeric value that represents the center of collection of numbers.\n\n- Constraints:\n\n  - The input array may contain positive and negative integers.\n  - The input array may be empty. If it is empty, the function should return 0.\n\n## Day 22\n\n#### Write a JS function findMedian(arr) that takes an array of numbers as input and returns the median value. If the array has an even number of elements, return the average of the two middle values\n\n##### For example, the median of 3, 3, 5, 9, 15 is 5. If there ia an even number of observations, then there is no single middl values; the median is then usually defined to be the mean of the two middle values: so the median of 3, 5, 7, 9 is (5+7)/2 = 6\n\n- todo\n\n  - Sort the array in ascending order.\n  - If the array has an odd number of elements, the median is the middle element.\n  - If the array has an even number of elements, the median is the average of the two middle elements.\n\n## Day 23\n\n#### Write a JS function to count the occurrences of each element in an array and store the counts in an object. The keys of the object should represent the elements of the array, and the values should represent the number of times each element appears in the array.\n\n- Note:\n\n  - Accept an array of numbers as input.\n  - Create an empty object called counts to store the counts of each element.\n  - Iterate through each number in the array.\n  - For each number, increment the count in the counts object.\n  - If the count for a number does not exist yet, initialize it to 1.\n  - Return the counts object containing the counts of each element.\n  - The input aray may contain positive integers only.\n  - You can assume that the input array is not empty.\n\n## Day 24\n\n#### Write a function called findMode that takes an array of numbers as input and returns the mode of the array (the number that appears most frequently).\n\n- Note:\n\n  - The input array will always contain at least one element.\n  - The mode will be unique (i.e., there won't be multiple numbers with the same highest frequency).\n\n## Day 25\n\n#### Write a function to calculate the factorial of a number (using Recursion)\n\n- Recursion is a programming technique where a function calls itself in order to solve a problem. Inessence, it's function that calls itself with smaller or simpler input until it reaches a base case\n\n- Base Case:\n\n  - The base case is the condition in a recursive function that stops the recursion. It's the point at which the function stops calling itself and returns a value without further recursion, Withput a base case the recursive function would continue calling itself indefinitely, leading to what's known as infinite recursion.\n\n- Recursive Case:\n\n  - It is the condition in a recursive function that determines when the function should call itself again. It's typically an expression or condition that evaluates to true for certain inputs, indicating that further recursion is necessary to solve the problem. Each recursive call should move closer to the base case, eventually leading to termination of the recursion\n\n## Day 26\n\n#### Write a function series is a sequence of numbers in which each number (Fibonacci number) is the sum of the two preceding ones. It starts with 0, 1, 1, 2, 3, 5, 8, 13, 21, ...\n\n- Note:\n  - Fibonacci number is calculated using formula:\n  - F(n)= F(n-1) + F(n-2), where, F(1) = F(2)= 1.\n\n## Day 27\n\n#### Write a function called repeatString that takes two parameters:\n\n- str: A string that needs to be repeated.\n- num: An integer representing the number of times the string should be repeated.\n- The function should repeat the input string str the specified number of times num and return the resulting string.\n\n- Note:\n\n  - The input string str will contain only alphanumeric characters and punctuation marks.\n  - The input number num will be a non-negative integer.\n  - The output string length should not exceed the length of str multiplied by num.\n\n## Day 28\n\n#### Write a function called truncateString tht takes two parameters:\n\n- str: A string tht needs to be truncated.\n- maxLength: An integer representing the maximum length of the string allowed.\n- The function should truncate the input string str if its length exceeds the specified maxLength. If trunction occurs, function should add '...' to the end of the trucated string.\n\n- Constraints:\n  - The input string str will contain only alphanumeric characters and punctution marks.\n  - The maximum length maxLength will be a positive integer.\n  - The output string length should not exceed maxLength + 3 characters due to the addition of '...'.\n\n## Day 29\n\n#### Write a function called numberRange that generates an array containing consecutive numbers from a to b (inclusive)\n\n- Input:\n\n  - a: An integer representing the starting number of the range.\n  - b: An integer representing the ending number of the range.\n  - arr: An optional parameter representing the array to store the numbers in the range. It defaults to an empty array.\n\n- Output:\n\n  - An array containing consecutive numbers from a to b (inclusive).\n\n- Constraints:\n\n  - a and b will be integers.\n  - a will be less than or equal to b\n\n## Day 30\n\n#### Write a function called numberRangeRecursive that generates an array containing consecutive numbers from a to b (inclusive) (same as above)\n\n## Day 31\n\n#### Write a function called simplePasswordValidator that takes a single parameter\n\n- password: A string representing the password to be validated.\n  The function should validate the password based on following criteria:\n\n- The password must contain at least one lowercase letter, one uppercase letter, and one digit\n  The length of the password must be at least 8 characters\n  The function should return true if the password meets all the criteria, otherwise, it should return false\n\n- Input:\n\n  - password: A non-empty string representing the password to be validated.\n\n- Output:\n\n  - true if the password meets all the criteria\n  - false otherwise\n\n- Constraints\n  - The input string password will contain only alphanumeric characters and punctuation marks\n\n## Day 32\n\n#### Image Filter App\n\n## Day 33\n\n#### Write a function randomHexColor that generates a random hexadecimal color code each time it is called. The function should return a string representing the random color code in the format '#RRGGBB', where RR, GG \u0026 BB are two-digit hexadecimal numbers representing the red, green \u0026 blue components of the color, respectively.\n\n- your challenge is to implement the randomHexColor function using JS and ensure taht it produces a valid hexdecimal color code with a length of 7 characters (including the # symbol)\n\n- Constraints\n\n  - The output color should always start with # followed by six hexadecimal characters (RRGGBB).\n\n  - The function should not take any parameters.\n  - The generated color codes should be unique and evenly distributed across the entire range of possible hexadecml color codes\n\n- Hint\n  - converts the random number into a hexadecimal string representation\n\n## Day 34\n\n#### Write a function removeDuplicates that takes an array of elements as input and returns a new array with duplicaate elements removed.\n\n- your task is to implement the removeDuplicates function using JS and ensure that the returned array contains only unique elements from the input array. The order of elements in the output array should be the same as the original array, with the first occurrence of each unique element preserved.\n\n- Constraints:\n\n  - The input array may contain elements of any data type.\n  - The function should return a new array with duplicate elements removed, while preserving the order of elements from the original array.\n\n- You should use the provided removeDuplicates function signature without any additional parameters\n\n## Day 35\n\n#### Write a function isEmptyObject that takes an object as input and determines whether it is empty or not. An empty object is defined as an object with no own properties.\n\n- Almost everything in the JS is an object including arrays and functions or gets treated as an object\n\n- Your task is to implement the isEmptyObject function using JvaScript and return a message indicating whether the object is empty or not.\n\n- Constraints\n\n  - The input object may have any number of properties, including zero.\n\n  - The function should return a message indicating whether the object is empty or not.\n\n  - You should use the provided isEmptyObject function signature without any additional parameters\n\n# Interview Prep\n\nHappy Learning! ✨\n\nMade with ☕️ by Divyanshu Kashyap\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucky-kashyap%2Fjs-interview-practice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucky-kashyap%2Fjs-interview-practice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucky-kashyap%2Fjs-interview-practice/lists"}