{"id":27404765,"url":"https://github.com/ninja-vikash/javascript-brainstorming","last_synced_at":"2025-04-14T05:47:15.103Z","repository":{"id":228302030,"uuid":"771578420","full_name":"Ninja-Vikash/JavaScript-BrainStorming","owner":"Ninja-Vikash","description":"⚡JavaScript BrainStorming","archived":false,"fork":false,"pushed_at":"2024-06-30T09:46:34.000Z","size":215,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-07-02T01:50:35.256Z","etag":null,"topics":["classes","conditionals","dom-manipulation","eventhandling","functions","javascript","loops","objects","programming"],"latest_commit_sha":null,"homepage":"","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/Ninja-Vikash.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}},"created_at":"2024-03-13T14:57:05.000Z","updated_at":"2024-06-30T09:46:37.000Z","dependencies_parsed_at":"2024-06-14T17:26:38.419Z","dependency_job_id":null,"html_url":"https://github.com/Ninja-Vikash/JavaScript-BrainStorming","commit_stats":null,"previous_names":["ninja-vikash/javascript-collection"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ninja-Vikash%2FJavaScript-BrainStorming","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ninja-Vikash%2FJavaScript-BrainStorming/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ninja-Vikash%2FJavaScript-BrainStorming/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ninja-Vikash%2FJavaScript-BrainStorming/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ninja-Vikash","download_url":"https://codeload.github.com/Ninja-Vikash/JavaScript-BrainStorming/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248830418,"owners_count":21168272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["classes","conditionals","dom-manipulation","eventhandling","functions","javascript","loops","objects","programming"],"created_at":"2025-04-14T05:47:10.635Z","updated_at":"2025-04-14T05:47:15.078Z","avatar_url":"https://github.com/Ninja-Vikash.png","language":"JavaScript","readme":"##### JavaScript Brainstorming 📚\n\n# Getting Started\n\u003cimg src=\"logo.png\" height=\"100\" align=\"left\"/\u003e\n\n**Javascript** is one of the most important assets for **Web Developers.**\u003cbr/\u003e\nBut this is not very complicated language to understand 😮\u003cbr\u003e\nTo simplify the understanding of **JavaScript**\u003cbr/\u003e\nThis repo will help and boost your knowledge in **JavaScript**💡\n\n### Content table\n- Core Concepts of JavaScript ⚡\n    - [What is JavaScript ?](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#what-is-javascript-)\n    - [Features](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#features-of-javascript)\n    - [History](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#history-of-javascript-)\n    - [Core of Programming](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#core-of-programming-)\n- Jewels of JavaScript 💎\n    - [Array](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#array)\n    - [Class](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#class)\n    - [Conditionals](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#conditionals)\n    - [DOM (Data Object Model)](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#dom)\n    - [Events](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#events)\n    - [Function](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#function)\n    - [Loop](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#loop)\n    - [Math](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#math)\n    - [Objects](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#object)\n    - [Object Date](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#date)\n- [Exercises](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#exercises-%EF%B8%8F%EF%B8%8F) 🏋️‍♂️\n-  [Contribute](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#contribute-) 🤝\u003cbr/\u003e\nExplore the contribution section for more information and guidance\u003cbr/\u003e \nHow to contribute? 👆\n\n## Core Concepts of JavaScript 🤓\n### What is JavaScript ?\n- JavaScript is a **high-level**, **versatile programming language** primarily used for creating interactive and dynamic content on websites.\n- JavaScript allows developers to implement complex features such as **real-time** updates, **interactive** forms, **animations**, and **multimedia integration**.\n- JavaScript is an essential part of **web development**, working alongside HTML and CSS to enhance user experiences.\n- It is supported by all modern web browsers and can be used on both the **client side** (in the browser) and the **server side** (using environments like Node.js).\n\n### Features of JavaScript\n\n- Interpreted Language\n- Dynamic Typed\n- Object Oriented\n- DOM Manipulation\u003cbr/\u003e\n    Are the key-features of JavaScript\n\n### Where to write JavaScript ?\n1. Directly in your **browser's console**.\n2. Inside a `HTML` file using `\u003cscript\u003e` tag\n    ```html\n    \u003cscript\u003e\n        console.log(\"Hello World!\")\n    \u003c/script\u003e\n    ```\n3. Using a external JavaScript file\n    ```js\n    // index.js\n    console.log(\"Hello World!\")\n    ```\n    Or,\n4. We can run our javascript file using a extension `code runner` in vs-code\u003cbr/\u003e\n    Suppose we have a JavaScript file named as `index.js`\u003cbr/\u003e\n    Go to the `terminal` window in vs-code and run the command\n    ```bash\n    node index.js\n    ```\n\u003e [!IMPORTANT]\\\n\u003e The above node command will only work, If you have intalled node.js in your machine.\n\n### History of JavaScript ⌛\n\n#### Creation\n- In 1995, **Netscape Communications Corporation** wanted a lightweight scripting language for its **Netscape Navigator web browser**.\n- *Brendan Eich*, a programmer at Netscape, **created JavaScript in just 10 days**. Initially called \"`Mocha`,\" it was later renamed \"`LiveScript`\" and finally \"`JavaScript`\" to capitalize on the popularity of **Java**.\n\n#### Early Development\n- JavaScript was released with **Netscape Navigator 2.0** in 1995.\n- Microsoft responded by creating a similar language called JScript, which was included in **Internet Explorer 3.0** in 1996.\n\n#### Standardization\n- To ensure compatibility across different browsers, JavaScript was standardized by the **European Computer Manufacturers Association (ECMA)**.\n- The first standardized version, **ECMAScript 1** (ES1), was released in 1997.\n\n#### Growth and Evolution\n- Subsequent versions introduced more features and improvements. Notably, ECMAScript 3 (ES3) in 1999 added regular expressions, better string handling, and new control statements.\n- ECMAScript 4 (ES4) was ambitious but never fully realized due to disagreements within the community.\n\n#### Modern JavaScript\n- **ECMAScript 5** (ES5) was released in 2009, bringing significant features like `strict mode`, `JSON support`, and more robust object properties.\n- **ECMAScript 6** (ES6) or ECMAScript 2015 was a major update in 2015, introducing `classes`, `modules`, `arrow functions`, `let` and `const` keywords, and `promises`.\n- Since ES6, the language has received yearly updates, with ECMAScript 2016 (ES7), ECMAScript 2017 (ES8), and so on, each adding new features and improvements.\n\n#### JavaScript Today\n- JavaScript is now a powerful, full-fledged programming language used for both **client-side** and **server-side** development.\n- It is the backbone of modern web development, supported by vast ecosystems, including libraries like **React**, **Angular**, and **Vue**, and runtime environments like **Node.js**.\n\n***\n### Core of Programming 🧠\n\n**Print**\u003cbr/\u003e\nIn JavaScript we use `console.log()` to print\n```js\nconsole.log(\"Hello World!\")\n```\n\n**Comments**\u003cbr/\u003e\nComments are used to inhance readability or prevent execution of any code block.\n```js\n// Single line comment\n\n/*\n  This is\n  multi-line\n  comment\n*/\n```\n\n**Variables**\u003cbr/\u003e\nVariables are like containers to store data.\u003cbr/\u003e\nIn JavaScript we can create a variable using `var`, `let` or `const` keyword.\n\u003e [!IMPORTANT]\\\n\u003e In modern JavaScript\\\n\u003e `let` \u0026 `const` keywords are used for most of the coding.\n\n**Declaration vs Assigning**\n```js\nlet myName;         // Variable declaration part\n\nmyName = \"Vikash\";  // Variable assigning part\n```\n\n**Data Types**\u003cbr/\u003e\nAt a very high level, there are two types of data types in JavaScript\n1. Primitive Data Types\u003cbr/\u003e\n    `undefined`, `null`, `numbers`, `string`, `boolean`, `symbol`\n2. Reference Data Types\u003cbr/\u003e\n    `Arrays` and `Object`\n\n\n`var` vs `let` \u0026 `const`\n```js\n// Declaration using var keyword\nvar myName = \"Vikash\"\n\nconsole.log(myname)         // Vikash\n```\n\u003e [!WARNING]\\\n\u003e `var` keyword supports `Hoisting` method to declare a variable.\\\n\u003e `Hoisting` breaks the variable statement into two parts as\n\u003e ```js\n\u003e var myName;\n\u003e myName = \"Vikash\";\n\u003e ```\n\u003e And moves the declaration part on the top of the file\\\n\u003e Initially the variable stored as `undefined` value during the memory creation phase.\\\n\u003e If we try to access the variable before declaring it will print the special keyword `undefined`.\n\u003e ```js\n\u003e console.log(myName);          // Undefined\n\u003e var myName = \"Vikash\";\n\u003e ```\n\nIn modern JavaScript, Most of the time we will use `let` and `const` keyword to declare a variable.\n```js\n// Declaration using let keyword\nlet myName = \"Vikash\";\n\nconsole.log(myName);            // Vikash\n```\n\u003e [!NOTE]\\\n\u003e When we create a variable using `let` keyword, We have access to re-assign the value.\n\u003e ```js\n\u003e let myName = \"Vikash\";\n\u003e \n\u003e console.log(myName);          // Vikash \n\u003e\n\u003e myName = \"Ninja Vikash\";\n\u003e\n\u003e console.log(myName);          // Ninja Vikash \n\u003e ```\n```js\n// Declaration using const keyword\nconst myName = \"Vikash\";\n\nconsole.log(myName);            // Vikash\n```\n\u003e [!WARNING]\\\n\u003e We cannot re-assign a variable declared using `const` keyword\n\u003e\n\u003e `let` and `const` don't support `Hoisting` method.\\\n\u003e If we try to access a variable declared using `let` and `const` keyword.\n\u003e ```js\n\u003e console.log(myName);\n\u003e\n\u003e const myName = \"Vikash\";\n\u003e ```\n\u003e It will through an error.\n\u003e ```\n\u003e ReferenceError: Cannot access 'myName' before initialization\n\u003e ```\n\n#### Primitive Data Types\nSince, **JavaScript is not a typed Language**.\u003cbr/\u003e\nTherefore, We don't need to define data type of any variable `explicitly`\u003cbr/\u003e\nJavaScript is smart enough to identify the variable type\u003cbr/\u003e\nFor checking the data type of any variable we use `typeof()` method.\u003cbr/\u003e\n\n```js\nlet num1 = 123;\nlet num2 = 99.56;\n\nconsole.log(typeof(num1));          // number\n\nlet str1 = \"Vikash\";\nlet str2 = \"Kumar\";\n\nconsole.log(typeof(str1));          // string\n\nlet isCodingFun = true;\n\nconsole.log(typeof(isCodingFun))    // boolean\n\nlet undValue;\n\nconsole.log(typeof(undValue));      // undefined\n\nlet nulValue = null;\n\nconsole.log(typeof(nulValue));      // object\n```\n\n#### Operators\nOperators are used to perform some task on variables.\u003cbr/\u003e\n- **Arithmetic Operator**\n    - Addition `(+)`\n    - Subtraction `(-)`\n    - Multiplication `(*)`\n    - Division `(/)`\n    - Modulas `(%)`\n- **Assignment Operator**\n    - `a = 2`\n    - `a += 2`\n    - `a -= 2`\n    - `a *= 2`\n    - `a /= 2`\n    - `a %= 2`\n- **Comparison Operator**\n    - Greater than `x \u003e y`\n    - Less than `x \u003c y`\n    - Greater than or Equal to `x \u003e= y`\n    - Less than or Equal to `x \u003c= y`\n    - Equal-equal to `x == y`\n    - Not equal to `x != y`\n- **Logical Operator**\n    - AND `\u0026\u0026`\n    - OR `||`\n    - NOT `!`\n\n## Jewels of JavaScript 💎\n- Array\n    - [What is an Array?](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#array)\n    - [Exercise](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#exercise-array)\n- Conditionals\n    - [If-else and Switch](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#conditionals)\n    - [Exercise](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#exercise-conditionals)\n- Class\n    - What is class?\n- DOM (Data Object Model)\n    - What is DOM?\n    - DOM Operations\n- Events\n    - What is an Event in JavaScript?\n    - Common Events\n    - Event Handling\n- Function\n    - [What is a Function?](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#function)\n    - [Exercise](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#exercise-function)\n- Loop\n    - [What is Loop?](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#loop)\n    - [Exercise](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#exercise-loop)\n- Math\n    - Math Object in JavaScript\n    - List of Math method\n- Object\n    - [What is an Object?](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#object)\n    - [Exercise](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#exercise-object)\n- Object Date\n\n\n## Exercises 🏋️‍♂️\n### Exercise Array\n- [Generate table using array](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#generate-table-using-array)\n- [Get even or odd numbers from the array list](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#get-even-or-odd-numbers-from-the-array-list)\n- [Create counting table up to 100 using the array list of 10 elements](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#create-counting-table-upto-100-using-the-array-list-of-10-elements)\n- [Insertion in Array](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#insertion-in-array)\n- [Deletation in Array](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#deletation-in-array)\n- [Basic methods in Array](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#basic-methods-in-array)\n- [Replace any particular value from the array list](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#replace-any-particular-value-from-the-array-list)\n- [Array destructuring *](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#array-destructuring-)\n- [Case changing of a string elements in an array list](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#case-changing-of-a-string-elements-in-a-array-list)\n- [Change the CASE of elements in a dynamic array](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#case-changing-of-elements-in-a-dynamic-array)\n- [Get candidates who can apply for government job](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#get-candidates-who-can-apply-for-government-job)\n- [Printing each individual element using for-each loop](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#printing-each-individual-element-using-for-each-loop)\n- [Reverse Array](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#reverse-array)\n\n### Exercise Conditionals\n- [Eligiblity check for voting](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#eligiblity-check-for-voting)\n- [Advanced eligibility check](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#advanced-eligibility-check)\n- [Workout schedule](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#workout-schedule)\n- [Get exponential values of any single or a range](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#get-exponential-values)\n\n### Exercise Function\n- [A normal function to print welcome note](https://github.com/Ninja-Vikash/JavaScript-Collection?tab=readme-ov-file#a-normal-function-to-print-welcome-note)\n- [A arrow function to print welcome note](https://github.com/Ninja-Vikash/JavaScript-Collection?tab=readme-ov-file#a-arrow-function-to-print-welcome-note)\n- [Calculate total marks and grade](https://github.com/Ninja-Vikash/JavaScript-Collection?tab=readme-ov-file#calculate-total-marks-and-grade)\n- [For getting square of one and more values](https://github.com/Ninja-Vikash/JavaScript-Collection?tab=readme-ov-file#for-getting-square-of-one-and-more-values)\n- [To understand implicit return in arrow function](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#to-understand-implicit-return-in-arrow-function)\n- [A high-order function to get square, cube \u0026 quad values of any number](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#to-get-power-value-from-passed-argument)\n\n### Exercise Loop\n- [Construct a table for any number using loop](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#construct-a-table-for-any-number-using-loop)\n- [For getting a square table](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#for-getting-a-square-table)\n- [For getting exponential values of any range or a single value](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#for-getting-exponential-values-of-any-range-or-a-single-value)\n- [Form an Infinite loop](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#form-an-infinite-loop)\n- [Usage of for-in loop](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#usage-of-for-in-loop)\n- [Usaage of for-of loop and for-each loop](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#usaage-of-for-of-loop-and-for-each-loop)\n- [Break and continue statement](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#break-and-continue-statement)\n\n### Exercise Object\n- [Create an object](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#create-an-object)\n- [Add new values and Update values in the existing object at once](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#add-new-values-and-update-values-in-the-existing-object-at-once)\n- [Create an object for student marks entry and get total marks, grade](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#create-an-object-for-student-marks-entry-and-get-total-marks-grade)\n- [Course Constructor \u0026 Data Viewer](https://github.com/Ninja-Vikash/JavaScript-Collection/blob/main/README.md#course-constructor--data-viewer)\n\n\u003cbr/\u003e\n\n## Array\n### What is an array?\nAn Array is a **collection of data** in a list.\u003cbr/\u003e\nArray can hold elements of any type, including `numbers`, `strings`, `objects`, `functions`, and even other `arrays`\n```js\nlet array = [1, 2, 3, 4, 5, 6, 7, 8, 9];\n```\nEach value inside of an array is known as an `element` and each element has its own `index`\n```js\nlet array = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n\narray.indexOf(2)    // OUTPUT : 1\n```\nIn the array index value starts from `0(zero)`\u003cbr/\u003e\nJavaScript arrays come with a variety of built-in methods for common tasks such as *adding*, *removing*, or *iterating* over elements.\u003cbr/\u003e\n**Reference**: [w3schools](https://www.w3schools.com/js/js_array_methods.asp)\n| [mdn](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\n| [geeksforgeek](https://www.geeksforgeeks.org/javascript-array-methods/)\n\n### Exercise Array\n#### Generate table using array.\n```js\n// ------\u003e Code for generating table\nlet arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n\nfunction Table(n){\n    let table = arr.map((e)=\u003e e*n)\n    console.log(`Table of ${n}`);\n\n    table.forEach((element) =\u003e {\n        console.log(element);\n    });\n}\n\n// Pass value for getting the table\nTable(132)\n```\n\n#### Get even or odd numbers from the array list\n```js\n// ------\u003e Checking using multiple functions\nlet arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n\nconst Even = () =\u003e {\n  let even = arr.filter((e) =\u003e e % 2 == 0);\n  console.log(even);\n};\n\nEven()\n\nconst Odd = () =\u003e {\n  let odd = arr.filter((e) =\u003e e % 2 == 1);\n  console.log(odd);\n};\n\nOdd()\n```\n```js\n// ------\u003e Checking using a single function\nlet arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n\nfunction get(numType){\n\n    let result = arr.filter((e) =\u003e {\n        if (numType == \"even\") {\n            return e % 2 == 0\n        }\n        else\n        if (numType == \"odd\") {\n            return e % 2 == 1\n        }\n    });\n\n    if (numType == \"even\" || numType ==\"odd\"){\n        console.log(result);\n    }\n\n    else {\n        console.log(\"Please enter a valid type!\")\n    }\n}\n\nget(\"even\")\n// get(\"odd\")\n// get(\"red\")\n```\n\n#### Create counting table upto 100 using the array list of 10 elements\n```js\nlet arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\nlet arr2 = arr1.map((e) =\u003e e + 10);\nlet arr3 = arr2.map((e) =\u003e e + 10);\nlet arr4 = arr3.map((e) =\u003e e + 10);\nlet arr5 = arr4.map((e) =\u003e e + 10);\nlet arr6 = arr5.map((e) =\u003e e + 10);\nlet arr7 = arr6.map((e) =\u003e e + 10);\nlet arr8 = arr7.map((e) =\u003e e + 10);\nlet arr9 = arr8.map((e) =\u003e e + 10);\nlet arr10 = arr9.map((e) =\u003e e + 10);\n\nlet finalArr = arr1.concat(arr2,arr3,arr4,arr5,arr6,arr7,arr8,arr9,arr10);\nconsole.log(...finalArr)\n\n/**\n *  NOTE : For concatenation, I used the (...)spread operator\n */\n```\n#### Insertion in Array\n```js\n// ------\u003e Inserting in an empty array\n\nlet arr = []\nfunction insert (...val){\n    arr.push(...val)\n}\n\ninsert(\"Hello\", \"World\", \"!\")\nconsole.log(arr)\n```\n```js\n// ------\u003e Inserting in an existing array using PUSH\nlet studentName = [\"Vikash\", \"Anuj\", \"Shiv\", \"Rohit\", \"Sanjay\"];\n\nconst add = (...value)=\u003e{\n    studentName.push(...value)\n}\n\nadd(\"Sanjeev\", \"Kumar\", \"Suraj\")\n\nconsole.log(studentName)\n\n// ------\u003e Using UNSHIFT\nconst addBegin = (...value)=\u003e{\n    studentName.unshift(...value)\n}\n\naddBegin(\"Aditi\", \"Nandini\", \"Sneha\")\n\nconsole.log(studentName)\n```\n#### Deletation in Array\n```js\n// ------\u003e Deletation using POP\nlet studentName = [\"Vikash\", \"Anuj\", \"Shiv\", \"Rohit\", \"Sanjay\"];\n\nfunction remove (n){\n    for (let i = 0; i \u003c n; i++) {\n        studentName.pop()\n    }\n}\n\nremove(4)\n\nconsole.log(studentName)\n```\n```js\n// ------\u003e Advanced code\nlet studentName = [\"Vikash\", \"Anuj\", \"Shiv\", \"Rohit\", \"Sanjay\"];\n\nfunction remove (n){\n    if (n \u003c= studentName.length \u0026\u0026 n \u003e= 0) {\n        for (let i = 0; i \u003c n; i++) {\n            studentName.pop()\n        }\n        console.log(studentName)\n    }\n    else {\n        console.log(\"Please enter lesser value than the array length\")\n    }\n}\n\nremove(6)\n```\n```js\n// ------\u003e Deletation using SHIFT\nlet studentName = [\"Vikash\", \"Anuj\", \"Shiv\", \"Rohit\", \"Sanjay\"];\n\nfunction removeBegin (n){\n    for (let i = 0; i \u003c n; i++) {   \n        studentName.shift()\n    }\n}\n\nremoveBegin(1)\nconsole.log(studentName)\n```\n```js\n// ------\u003e Advanced code\nlet studentName = [\"Vikash\", \"Anuj\", \"Shiv\", \"Rohit\", \"Sanjay\"];\n\nfunction removeBegin (n){\n    if (n \u003c= studentName.length) {\n        for (let i = 0; i \u003c n; i++) {\n            studentName.shift()\n        }\n        console.log(studentName)\n    }\n    else {\n        console.log(\"Please enter lesser value than the array length\")\n    }\n}\n\nremoveBegin(5)\n```\n```js\n// ------\u003e SPLICE METHOD\nlet studentName = [\"Vikash\", \"Anuj\", \"Shiv\", \"Rohit\", \"Sanjay\"];\n\nstudentName.splice(2,5)\n\nconsole.log(studentName)\n```\n#### Basic methods in Array \n```js\nlet studentName = [\"Vikash\", \"Anuj\", \"Shiv\", \"Rohit\", \"Sanjay\"];\n\nlet getIndex = studentName.indexOf(\"Sanjay\")\nconsole.log(getIndex)\n\nlet getValue = studentName[1]\nconsole.log(getValue)\n\nlet sliced = studentName.slice(2, 3)\nconsole.log(sliced)\n```\n\n#### Replace any particular value from the array list\n```js\nlet studentName = [\"Vikash\", \"Anuj\", \"Shiv\", \"Rohit\", \"Sanjay\"];\n\nstudentName[2] = \"King\"\nstudentName[0] = \"VIAKSH\"\nconsole.log(studentName)\n```\n\n#### Array destructuring *\n```js\nlet studentName = [\"Vikash\", \"Anuj\", \"Shiv\", \"Rohit\", \"Sanjay\"];\nlet secondList = [\"Ankush\", \"Sid\"]\n\n// -------\u003e Merging two arrays\nstudentName = [...studentName, ...secondList]\n// studentName = studentName.concat(secondList)\nconsole.log(studentName)\n\n// -------\u003e Getting value\nlet [a, b, ...rest] = studentName\nconsole.log(a)\nconsole.log(b)\nconsole.log(rest)\n\nlet [x, y, , ,...other] = studentName\nconsole.log(x)\nconsole.log(y)\nconsole.log(other)\n\n/**\n *  NOTE : A blank comma separation will skip value in Destructuring\n */\n```\n\n#### Case changing of a string elements in a array list\n```js\n// -------\u003e Using multiple functions\nlet studentName = [\"Vikash\", \"Anuj\", \"Shiv\", \"Rohit\", \"Sanjay\"];\n\nfunction ToUpper (){\n    let upper = studentName.map(e=\u003e e.toUpperCase())\n    console.log(upper)\n}\n\nToUpper()\n\nfunction ToLower (){\n    let lower = studentName.map(e=\u003e e.toLowerCase())\n    console.log(lower)\n} \n\nToLower()\n\n/**\n *  NOTE : We can't change the existing Array's string case\n *  but we can form a new array using the old array.\n */\n```\n```js\n// -------\u003e Using a single function\nlet studentName = [\"Vikash\", \"Anuj\", \"Shiv\", \"Rohit\", \"Sanjay\"];\n\nfunction toCase(change){\n    if(change == \"UPPER\"){\n        let newlist = studentName.map(e=\u003ee.toUpperCase())\n        console.log(newlist)\n    }\n    else\n    if(change == \"LOWER\"){\n        let newlist = studentName.map(e=\u003e e.toLowerCase())\n        console.log(newlist)\n    }\n    else {\n        console.log(\"Please enter a valid operation.\")\n    }\n}\n\ntoCase(\"UPPER\")\n// toCase(\"LOWER\")\n// toCase(\"HYPER\")\n```\n#### Case changing of elements in a dynamic array\n```js\nlet studentName = [];\n\nfunction addStudent(...names) {\n  studentName.push(...names);\n}\n\nfunction toCase(change) {\n  if (change == \"UPPER\") {\n    let newlist = studentName.map((e) =\u003e e.toUpperCase());\n    console.log(newlist);\n  } else if (change == \"LOWER\") {\n    let newlist = studentName.map((e) =\u003e e.toLowerCase());\n    console.log(newlist);\n  } else {\n    console.log(\"Please enter a valid operation.\");\n  }\n}\n\n// ------\u003e Insert names here\naddStudent(\"vikash\", \"rajiv\", \"sanjay\", \"hari\")\n\n// ------\u003e Get your output value\ntoCase(\"UPPER\");\n// toCase(\"LOWER\")\n// toCase(\"HYPER\")\n```\n\n#### Get candidates who can apply for government job\n```js\n// ------\u003e Candidate data\nlet candidate = [\n    {\n        name: \"Vikash\",\n        age: 20\n    },\n    {\n        name: \"Alice\",\n        age: 25\n    },\n    {\n        name: \"Bob\",\n        age: 30\n    },\n    {\n        name: \"Charlie\",\n        age: 35\n    },\n    {\n        name: \"David\",\n        age: 40\n    },\n    {\n        name: \"Emily\",\n        age: 22\n    },\n    {\n        name: \"Frank\",\n        age: 28\n    },\n    {\n        name: \"Grace\",\n        age: 32\n    }\n];\n\nfunction candidateSelector (min, max){\n    candidate.filter(e=\u003e{\n        if(e.age \u003c= max \u0026\u0026 e.age \u003e= min){\n            console.log(`Name = ${e.name} | Age = ${e.age}`)\n        }\n    })\n}\n\n// Pass age range in the function\ncandidateSelector(19, 33)\n```\n#### Printing each individual element using for-each loop\n```js\nlet nums = [1, 2, 3, 4, 5, 6, 7, 8, 9];\n\nfunction getList(){\n    nums.forEach((element,index)=\u003e{\n        console.log(`Value at index ${index} is ${element}`)\n    })\n}\n\ngetList()\n```\n#### Reverse Array\n```js\nlet num = [1, 2, 3, 4, 5, 6, 7, 8, 9];\n\n// ------\u003e By using reverse method\nfunction reverse (){\n    let newNum = num.reverse()\n    console.log(newNum)\n}\n\nreverse()\n\n// ------\u003e By using for loop\nfunction reverse (){\n    let newNum = []\n    \n    for (let i = num.length - 1; i \u003e= 0; i--){\n            newNum.push(num[i])\n        }\n    console.log(newNum)\n}\n\nreverse()\n```\n\n\u003cbr/\u003e\n\n## Class\n### What is class ?\nIn JavaScript, classes are a way to create **reusable blueprints** for objects.\u003cbr/\u003e\nClasses were introduced in ECMAScript 6 (ES6) and provide a more structured and syntactically sugar-coated way to work with `prototypes` and `inheritance`.\n\n- Classes: Use the `class` keyword to define a class\n- Constructor: The `constructor` method is used to initialize object properties.\n    ```js\n    class Person {\n    // Constructor method to initialize the object\n        constructor(name, age) {\n            this.name = name;\n            this.age = age;\n        }\n    }\n\n    // Creating an instance of the Person class\n    let person1 = new Person('Vikash', 20);\n    console.log(person1.describe()); // Vikas is 20 years old.\n    ```\n- Instance Methods: Methods that operate on instances of the class.\n    ```js\n    class Person {\n        constructor(name, age) {\n            this.name = name;\n            this.age = age;\n        }\n\n        describe() {\n            return `${this.name} is ${this.age} years old.`;\n        }\n    }\n\n    let person1 = new Person('Ninja Vikash', 20);\n    console.log(person1.describe()); // Ninja Vikash is 20 years old.\n    ```\n- Static Methods: Methods that belong to the class itself.\n    ```js\n    class Person {\n        constructor(name, age) {\n            this.name = name;\n            this.age = age;\n        }\n\n        describe() {\n            return `${this.name} is ${this.age} years old.`;\n        }\n\n        // Static method\n        static species() {\n            return 'Homo sapiens';\n        }\n    }\n\n    console.log(Person.species()); // Homo sapiens\n    ```\n- Inheritance: Use the `extends` keyword to create a subclass and `super` to call the parent class's constructor.\n    ```js\n    class Person {\n        constructor(name, age) {\n            this.name = name;\n            this.age = age;\n        }\n\n        describe() {\n            return `${this.name} is ${this.age} years old.`;\n        }\n    }\n\n    class Student extends Person {\n        constructor(name, age, role) {\n            super(name, age); // Call the constructor of the parent class\n            this.role = role;\n        }\n\n        describe() {\n            return `${this.name} is ${this.age} years old and a ${this.role}.`;\n        }\n    }\n\n    let student1 = new Student('Vikash', 20, 'Coder');\n    console.log(student1.describe()); // Vikash is 20 years old and a Coder.\n    ```\n\n\u003e [!IMPORTANT]\\\n\u003e The only important method in class is `constructor` method, In which we create instances.\n\n**Reference** : [mdn](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) | \n[w3schools](https://www.w3schools.com/js/js_classes.asp)\n\n\u003cbr/\u003e\n\n## Conditionals\n### What is a conditional statement ?\nA conditional statement in programming is a feature that allows you to perform different actions based on whether a certain condition is `true` or `false`\u003cbr/\u003e\nIn JavaScript, conditional statements help control the flow of the code by executing specific blocks of code only if certain conditions are met.\n\n1. if-else statement\n```js\n// ------\u003e Single if statement\n\nif (condition){\n    // Statement\n}\n\n// ------\u003e if-else statement\n\nif (condition){\n    // Statement\n}\nelse{\n    // Statement\n}\n\n// ------\u003e if-else ladder\n\nif (condition){\n    // Statement\n}\nelse\nif(condition){\n    // Statement\n}\nelse{\n    // Statement\n}\n```\n2. Switch case statement\n```js\nswitch (key) {\n    case value:\n        // Statement\n        break;\n\n    default:\n        // Default Statement\n        break;\n}\n```\n**Reference** : [mdn](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/conditionals) | \n[w3schools](https://www.w3schools.com/js/js_if_else.asp)\n\n### Exercise Conditionals\n#### Eligiblity check for voting\n```js\n// Single if statement\nfunction EligiblityCheck(name,age){\n    if (age \u003e=18) {\n        console.log(`${name}, You are eligible for voting!`)\n    }\n}\n\nEligiblityCheck(\"Akash\",30)\n```\n```js\n// if-else ladder statement\nfunction EligiblityCheck(name,age){\n    if (age \u003c 18) {\n        console.log(`${name}, You are not eligible for voting!`)\n    }\n    if(age \u003e=18 \u0026\u0026 age \u003c=65){\n        console.log(`${name}, You are eligible for voting!`);\n    }\n    else \n    if(age \u003e 65){\n        console.log(`${name}, You are eligible!`)\n    }\n}\n\nEligiblityCheck(\"Akash\",64)\n```\n#### Advanced eligibility check\n```js\n// Strictly checks the condition\nfunction EligiblityCheck(...arg){\n    let voterName = arg[0]\n    let age = arg[1]\n\n    if(arg.length == 1){\n        console.log(\"Kindly pass your age as second argument\");\n    }\n    else\n    if(arg.length == 2){\n        if(typeof(voterName)==\"string\"){\n\n            if(age \u003e 0){\n                if (age \u003c 18) {\n                    console.log(`${voterName}, You are not eligible for voting!`);\n                }\n                else\n                if(age \u003e=18 \u0026\u0026 age \u003c=65){\n                    console.log(`${voterName}, You are eligible for voting!`);\n                }\n                else \n                if(age \u003e 65){\n                    console.log(`${voterName}, You are eligible!`);\n                }\n            }\n            else{\n                console.log(\"Please insert a valid age\");\n            }\n\n        }\n        else{\n            console.log(\"Please pass your name as first argument\");\n        }\n    }\n    else\n    if(arg.length \u003e 2){\n        console.log(`You have passed ${arg.length} arguments.`);\n    }\n}\n\n// EligiblityCheck(\"Vikash\")\nEligiblityCheck(\"Vikash\", 20)\n// EligiblityCheck(\"Vikash\", 20, 21)\n\n/**\n *  EligiblityCheck(_NAME_,_AGE_)\n *  Pass your name as first argument and your age as second argument\n *  You can try by passing only one or more than arguments as well as by not passing name as first arguemnt\n */\n```\n#### Workout schedule\n```js\nfunction workout(day){\n    let dayName = day.toUpperCase()\n    \n    switch (dayName) {\n        case \"SUN\":\n            console.log(\"LEG WORKOUT DAY\")\n            break;\n        case \"MON\":\n            console.log(\"LEG WORKOUT DAY\")\n            break;\n        case \"TUE\":\n            console.log(\"REST\")\n            break;\n        case \"WED\":\n            console.log(\"BICEP \u0026 BACK WORKOUT DAY\")\n            break;\n        case \"THU\":\n            console.log(\"BICEP \u0026 BACK WORKOUT DAY\")\n            break;\n        case \"FRI\":\n            console.log(\"CHEST WORKOUT DAY\")\n            break;\n        case \"SAT\":\n            console.log(\"CHEST WORKOUT DAY\")\n            break;\n        default:\n            console.log(\"PLEASE ENTER A VALID DAY.\")\n            break;\n    }\n}\n\nworkout(\"FRI\")\nworkout(\"Thu\")\n\n/**\n *  NOTE : Enter a valid day name to get your workout schedule\n */\n```\n\n#### Get exponential values\n```js\nfunction power(...args) {\n    let [expo, start, end] = args;\n\n    if(args.length \u003e 3){\n        console.log(\"Pass only 3 or less arguments\");\n    }\n    else{\n        if (start != undefined \u0026\u0026 end != undefined) {\n            for (let i = Math.min(start , end); i \u003c= Math.max(start, end); i++) {\n              console.log(`${i}^${expo}= ${Math.pow(i, expo)}`);\n            }\n        }\n        else\n        if(expo == undefined) {\n            console.log(\"Pass atleast two arguments\");\n        }\n        else\n        if (start == undefined) {\n            console.log(\"Pass Second Argument\");\n        }\n        else {\n            console.log(`${start}^${expo} = ${Math.pow(start, expo)}`);\n        }\n    }\n  }\n  \n  power(2, 12, 1);\n\n/**\n *  power(EXPONENT, START, END)\n *  You can get power value of any range or any order\n */\n```\n\n\u003cbr/\u003e\n\n## Function\n### What is a Function?\nA function in JavaScript is a block of code designed to perform a specific task.\u003cbr/\u003e\nIt allows you to **encapsulate logic**, making your code more **reusable** and easier to understand.\u003cbr/\u003e\nFunctions can take input through `parameters` and return a value or output.\n```js\nfunction addNumbers(a, b) {\n  let result = a + b;\n  return result;\n}\n\n// Call the function\nlet sum = addNumbers(3, 4);\nconsole.log(sum); // Output: 7\n```\n\n**Reference** : [w3schools](https://www.w3schools.com/js/js_functions.asp) | \n[mdn](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions) |\n[geeksforgeeks](https://www.geeksforgeeks.org/functions-in-javascript/)\n\n### Exercise Function\n#### A normal function to print welcome note\n```js\nfunction Welcome(user){\n    console.log(`Hello ${user}!`)\n    console.log(\"Now, You are a part of JavaScript BrainStorming!\")\n    console.log(\"Keep Learning!\")\n}\n\nWelcome(\"Ninja\")\n```\n#### A arrow function to print welcome note\n```js\nconst congrats = (candidate)=\u003e{\n    console.log(\"Congratulations! \" + candidate + \" for performing excellent in the test.\")\n}\n\nconst congratulation = (candidate)=\u003e{\n    console.log(`Congratulations! ${candidate} for performing excellent in the test.`)\n}\n\ncongrats('ninja')\ncongratulation('vikash')\n```\n#### To understand implicit return in arrow function\n```js\n// ------\u003e Sum of two numbers using normal function\nfunction add (a, b){\n    return a + b\n}\n\nlet sum = add(23, 23)\nconsole.log(sum)\n```\n```js\n// ------\u003e Sum of two numbers using arrow function with explicit return\nlet add = (a, b)=\u003e{\n    return (\n        a + b\n    )\n}\n\nlet sum = add(23, 23)\nconsole.log(sum)\n```\n```js\n// ------\u003e Sum of two numbers using arrow function with implicit return\nlet add = (a, b) =\u003e a + b\n\nlet sum = add(23, 23)\nconsole.log(sum)\n```\n#### Calculate total marks and grade\n```js\nlet marksData = []\n\nfunction studentEntry(...marks){\n    console.log(\"STUDENT REPORT\")\n    marksData.push(...marks)\n\n    let [a, b, c, d, e] = marksData\n    let marksToSum = [a, b, c, d, e]\n    \n    let total = marksToSum.reduce((a,b)=\u003ea+b)\n    console.log(`TOTAL MARKS : ${total}`)\n\n    let grade = total/5\n    if(grade \u003c= 33){\n        console.log(`GRADE MARKS : 'F'`)\n    }\n    else\n    if (grade \u003e 33 \u0026\u0026 grade \u003c= 40) {\n        console.log(`GRADE MARKS : 'C'`)\n    }\n    else\n    if (grade \u003e 40 \u0026\u0026 grade \u003c= 48) {\n        console.log(`GRADE MARKS : 'C+'`)\n    }\n    else\n    if (grade \u003e 48 \u0026\u0026 grade \u003c= 54) {\n        console.log(`GRADE MARKS : 'B'`)\n    }\n    else\n    if (grade \u003e 54 \u0026\u0026 grade \u003c= 59) {\n        console.log(`GRADE MARKS : 'B+'`)\n    }\n    else\n    if (grade \u003e 59 \u0026\u0026 grade \u003c= 67) {\n        console.log(`GRADE MARKS : 'A'`)\n    }\n    else\n    if (grade \u003e 67 \u0026\u0026 grade \u003c= 84) {\n        console.log(`GRADE MARKS : 'A+'`)\n    }\n    else\n    if (grade \u003e 85 \u0026\u0026 grade \u003c= 89) {\n        console.log(`GRADE MARKS : 'A++'`)\n    }\n    else\n    if (grade \u003e 89 \u0026\u0026 grade \u003c= 100) {\n        console.log(`GRADE MARKS : 'EX'`)\n    }\n}\n\nstudentEntry(67, 76, 63, 98, 69)\n// studentEntry(88, 76, 66, 94, 73, 65)\n// studentEntry(20, 20, 20, 20, 20)\n\n/**\n *  NOTE : If you enter more than five values\n *  except initial five values all the other values will be neglected\n */\n```\n#### For getting square of one and more values\n```js\nfunction square(...value) {\n  let values = [];\n  values.push(...value);\n  if (values.length == 0) {\n    console.log(\"PLEASE ENTER AT LEAST ONE VALUE TO GET RESULT!\");\n  } else {\n    values.forEach((element) =\u003e {\n      console.log(`SQUARE OF ${element} is ${element ** 2}`);\n    });\n  }\n}\n\nsquare(4);\n// square();\n// square(2, 4, 5);\n\n/**\n *  NOTE : Pass values in the function to get squares, If you don't pass\n *  any single value in the function. A message will appear on the console.\n */\n```\n#### To get power value from passed argument\n```js\nfunction power(num, expo){\n    return expo(num)\n}\n\nfunction square(num){\n    console.log(`SQUARE OF ${num} : ${num**2}`)\n}\n\nfunction cube(num){\n    console.log(`CUBE OF ${num} : ${num**3}`)\n}\n\nfunction quad(num){\n    console.log(`QUAD OF ${num} : ${num**4}`)\n}\n\npower(3, square)\n```\n\n\u003cbr/\u003e\n\n## Loop\n### What is Loop?\nA loop in JavaScript is a programming tool used to repeat a set of instructions until a certain condition is met. \n\nThere are three main types of loops in JavaScript:\n1. for loop\n```js\nfor (initialization; condition; increment/decrement) {\n  // Code block to be executed\n}\n```\n2. while loop\n```js\nwhile (condition) {\n  // Code block to be executed\n}\n```\n3. do-while loop\n```js\ndo {\n  // Code block to be executed\n} while (condition);\n```\n\u003e [!IMPORTANT]\\\n\u003e `do-while` loop executes once the code block then it checks the condition.\n\n**Special loops**\n- **forEach loop**\u003cbr/\u003e\n    forEach loop is a special loop, which is used to iterate each elements of an array\n    ```js\n    let arr = [1, 2, 3, 4, 5];\n\n    arr.forEach(e =\u003e console.log(e));\n    ```\n- **for-of loop**\u003cbr/\u003e\n    for-of loop is used to iterate each elements of an array\n    ```js\n    let arr = [1, 2, 3, 4, 5];\n\n    for (const iterator of arr) {\n        console.log(iterator)\n    }\n    ```\n- **for-in loop**\u003cbr/\u003e\n    for-in loop is used to iterate each value of an object\n    ```js\n    let obj = {\n        name : \"vikash\",\n        role : \"coder\",\n        age : 20\n    }\n\n    for (const key in obj) {\n        const element = obj[key];\n        console.log(element, key)\n    }\n    ```\n\n**Reference** : [w3schools](https://www.w3schools.com/js/js_loop_for.asp) |\n[mdn](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration) | \n[freecodecamp](https://www.freecodecamp.org/news/javascript-loops-explained-for-loop-for/)\n\n### Exercise Loop\n#### Construct a table for any number using loop\n```js\n// ------\u003e Using for loop\nfunction Table(value){\n    for(let i = 1; i \u003c= 10; i++ ){\n        console.log(i*value)\n    }\n}\n\nTable(19)\n\n// ------\u003e Alternate\nconst Table = (val)=\u003e {\n    console.log(`TABLE OF ${val}`)\n    for(let i = val; i \u003c= val*10; i+=val ){\n        console.log(i)\n    }\n}\n\nTable(5)\n// Table(11)\n// Table(99)\n// Table(202)\n```\n```js\n// ------\u003e Using while loop\nconst Table = (num)=\u003e{\n    let i = 1\n    console.log(`TABLE OF ${num}`)\n    while (i\u003c=10) {\n        console.log(i*num);\n        i++\n    }\n}\n\nTable(13)\n\n// ------\u003e Alternate \nconst Table = (num)=\u003e{\n    let i = num\n    console.log(`Table of ${num} :`)\n    while (i\u003c=num*10) {\n        console.log(i);\n        i+=num\n    }\n}\n\nTable(24)\n```\n```js\n// ------\u003e Using do-while loop\nfunction Table (value){\n    let i = 1\n    console.log(`${value}'s table`)\n    do {\n        console.log(i*value);\n        i++\n    } while (i\u003c=10);\n}\n\nTable(23)\n\n// ------\u003e Alternate\nfunction Table (number){\n    let i = number\n    console.log(`${number}'s table`)\n    do {\n        console.log(i);\n        i+=number\n    } while (i\u003c=number*10);    \n}\n\nTable(7)\n```\n#### For getting a square table\n```js\nconst sqTable = (end)=\u003e{\n    for (let i = 1; i \u003c= end; i++) {\n        console.log(`SQUARE OF ${i} \\t = ${i*i}`)\n    }\n}\n\nsqTable(7)\n\n// ------\u003e Alternate\nconst sqTable = (end)=\u003e{\n    for (let i = 1; i \u003c= end; i++) {\n        console.log(`SQUARE OF ${i} \\t = ${i**2}`)\n    }\n}\n\nsqTable(10)\n\n/**\n *  NOTE : Both the operator will return the same value\n *  Use anyone of them\n */\n```\n#### For getting exponential values of any range or a single value\n```js\nfunction power(expo, start, end) {\n  if (start == undefined) {\n    console.log(\"PLEASE PASS AT LEAST TWO VALUES\");\n  } else if (end == undefined) {\n    for (let i = start; i \u003c= start; i++) {\n      console.log(`SQUARE OF ${i} = ${i ** expo}`);\n    }\n  } else {\n    for (let i = start; i \u003c= end; i++) {\n      console.log(`SQUARE OF ${i} = ${i ** expo}`);\n    }\n  }\n}\n\n// power(2);\n// power(2, 17);\npower(2, 17, 24);\n\n/**\n *  NOTE : power(exponent_value, start, end)\n *  We can get the exponent value of any single value\n *  By passing only two values as :\n *  power(exponent_value, start)\n */\n```\n\n#### Form an Infinite loop\n```js\n// ------\u003e Using while loop\nlet i = 1\nwhile (i\u003c=10) {\n    console.log(i*3);\n    // Declare an afterthought to avoid infinite loop \n}\n```\n```js\n// ------\u003e Using do-while loop\nlet i = 1\ndo {\n    console.log(i*3);\n    // Declare an afterthought to avoid infinite loop \n} while (i\u003c=10);\n```\n#### Usage of for-in loop\n```js\nlet OBJ = {\n    notebook : \"classmate\",\n    pencil : \"doms\",\n    eraser : \"doms\",\n    pen : \"fort\"\n}\n\nfor (const key in OBJ) {\n    const element = OBJ[key];\n    console.log(key, element)\n}\n\n/**\n *  NOTE : for-in loop specially used in objects\n */\n```\n#### Usaage of for-of loop and for-each loop\n```js\nlet ARRAY = [\"AKASH\", \"SHIV\", \"SONAL\", \"SNEHA\", \"VIKASH\"]\n\nfor (const iterator of ARRAY) {\n    console.log(iterator)\n}\n\nARRAY.forEach(element =\u003e {\n    console.log(element)\n});\n\n/**\n *  NOTE : for-of and forEach loop specially used in the array for iterating\n */\n```\n#### Break and Continue statement\n```js\nfor (let i = 1; i \u003c= 10; i++) {\n    console.log(\"I am \",i)\n    if(i==6){\n        break\n    }\n}\n\nfor (let i = 1; i \u003c= 10; i++) {\n    if(i==6){\n        break\n    }\n    console.log(\"I am \",i)\n}\n\nfor (let i = 1; i \u003c= 10; i++) {\n    if(i==6){\n        continue\n    }\n    console.log(\"I am \",i)\n}\n\n/**\n *  NOTE : break statement stops the chain\n *  while the continue statement continues the chain excluding the condition\n */\n```\n\n\u003cbr/\u003e\n\n## Object\n### What is an Object?\nAn object in JavaScript is a collection of `key-value` pairs where the keys are strings or symbols, and the values can be of any data type, including other objects.\u003cbr/\u003e\nObjects are used to store and organize complex data in a structured manner.\u003cbr/\u003e\nThey are created using `object literals`, `constructor functions`, or object creation methods like `Object.create()`\n\n1. **Using an object literal**:\n```js\nconst car = {\n  make: \"Toyota\",\n  model: \"Camry\",\n  year: 2022,\n  start: function() {\n    console.log(\"Engine started.\");\n  }\n};\n```\n2. **Using a constructor function**:\n```js\nfunction Person(name, age) {\n  this.name = name;\n  this.age = age;\n  this.sayHello = function() {\n    console.log(`Hello, my name is ${this.name} and I am ${this.age} years old.`);\n  };\n}\n\nconst person1 = new Person(\"Ninja Vikash\", 20);\nperson1.sayHello();\n```\n3. **Using `Object.create()`**:\n```js\nconst animal = {\n  speak: function() {\n    console.log(\"The animal makes a sound.\");\n  }\n};\n\nconst dog = Object.create(animal);\ndog.speak(); // Output: The animal makes a sound.\n```\n\n**Reference** : [mdn](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) |\n[w3schools](https://www.w3schools.com/js/js_objects.asp)\n\n### Exercise Object\n#### Create an object.\n```js\nfunction About (name, age, role, state){\n  this.name = name;\n  this.age = age;\n  this.role = role;\n  this.state = state;\n  this.data = ()=\u003e{\n    console.log(`Hi, I am ${this.name} and I am a ${this.age} years old ${this.role}. and I am based on ${this.state}.`)\n  }\n}\n\nconst Vikash = new About(\"Vikash Kumar\", 20, \"Developer\", \"Jharkhand\")\nVikash.data()\n```\n#### Add new values and Update values in the existing object at once.\n```js\nlet StudentData = {\n  name : \"Vikash\",\n  role : \"Web Developer\",\n  age : 20,\n  state : \"JH\",\n  status : \"Married\"\n}\n\nlet newData = {\n  country : \"INDIA\",\n  contact : 1234567890,\n  email : \"abc@gmail.com\"\n}\n\nlet update = {\n  name : \"Vikash Kumar\",\n  status : \"Single\"\n}\n\nStudentData = {...StudentData, ...newData, ...update}\nconsole.log(StudentData)\n```\n#### Create an object for student marks entry and get total marks, grade\n```js\nfunction studentEntry(...marks) {\n  let MARK = [];\n  MARK.push(...marks);\n\n  this.result = function () {\n    if (MARK.length \u003e 5 || MARK.length \u003c 5) {\n      console.log(\"PLEASE CHECK YOUR INPUT MARKS MAY BE YOU HAVE ENTERED MORE OR LESS INPUTS\");\n    } else {\n\n      let total = MARK.reduce((a, b) =\u003e a + b);\n      let grade = total / 5;\n\n      if (grade \u003e= 0 \u0026\u0026 grade \u003c 33) {\n        console.log(`YOUR SCORE IS : ${total} AND GRADE : F`);\n      } else if (grade \u003e= 33 \u0026\u0026 grade \u003c 45) {\n        console.log(`YOUR SCORE IS : ${total} AND GRADE : D`);\n      } else if (grade \u003e= 45 \u0026\u0026 grade \u003c 55) {\n        console.log(`YOUR SCORE IS : ${total} AND GRADE : C`);\n      } else if (grade \u003e= 55 \u0026\u0026 grade \u003c 65) {\n        console.log(`YOUR SCORE IS : ${total} AND GRADE : B`);\n      } else if (grade \u003e= 65 \u0026\u0026 grade \u003c 75) {\n        console.log(`YOUR SCORE IS : ${total} AND GRADE : A`);\n      } else {\n        console.log(`YOUR SCORE IS : ${total} AND GRADE : A+`);\n      }\n    }\n  };\n}\n\nlet Ajay = new studentEntry(30, 30, 30, 30);\n// Ajay.result()\nlet Rohit = new studentEntry(67, 56, 78, 56, 77);\nRohit.result()\nlet Sanjay = new studentEntry(90, 79, 56, 45, 44, 56);\n// Sanjay.result()\n```\n\n#### Course Constructor \u0026 Data Viewer\n```js\nfunction Course(...arg){\n  this.title = arg[0];\n  this.price = arg[1];\n  this.duration = arg[2];\n  this.author = \"Ninja-Vikash\"\n}\n\n// ------\u003e Create your course here\nlet DSA = new Course(\"DSA\", 1999, 4);\nlet JAVASCRIPT = new Course(\"JavaScript\", 1499, 6);\nlet HTML = new Course(\"HTML\", 799, 5);\nlet CSS = new Course(\"CSS\", 899, 3);\nlet REACT = new Course(\"React\", 1999, 8);\nlet NODEJS = new Course(\"Node.js\", 1799, 9);\n\n/**\n *  Pass values as Course(_course_name, _price, _duration)\n */\n\nfunction dataViewer(courseName){\n  console.log(\"---COURSE DETAILS---\")\n  for (const key in courseName) {\n    const value = courseName[key];\n    console.log(`${key} : ${value}`)\n  }\n  console.log(\"---COURSE DETAILS---\")\n}\n\n// ------\u003e Get Your course details\n// dataViewer(DSA)\n// dataViewer(REACT)\ndataViewer(NODEJS)\n// dataViewer(CSS)\n```\n\n\u003cbr/\u003e\n\n## DOM\n### What is DOM ?\nDOM stands for **Data Object Model**.\u003cbr/\u003e\nThe DOM represents a document as a **hierarchical tree structure** of nodes.\u003cbr/\u003e\nEach node can be an `element`, `attribute`, or `text` content.\u003cbr/\u003e\nThe nodes in the DOM tree are objects with **properties** and **methods**.\u003cbr/\u003e\n\u003e [!NOTE]\\\n\u003e `innerHTML` for content\\\n\u003e `style` for CSS styles\\\n\u003e `appendChild()` for add a new child node\n\n### DOM Operations\n#### Accessing elements\nWe can select elements using various methods like `getElementById()`, `getElementsByClassName()`, `getElementsByTagName()`, `querySelector()`, and `querySelectorAll()`.\n\n```js\n// Accessing an element by ID\nlet element = document.getElementById('myElement');\n\n// Accessing elements by class name\nlet elements = document.getElementsByClassName('myClass');\n\n// Accessing elements by tag name\nlet paragraphs = document.getElementsByTagName('p');\n\n// Accessing an element using a CSS selector\nlet firstParagraph = document.querySelector('p');\n```\n\u003e [!NOTE]\\\n\u003e `querySelector()` uses CSS selector syntax\\\n\u003e We can target any inner element as below\n\u003e ```js\n\u003e let element = document.querySelector(\".container h2\")\n\u003e ```\n\n#### Modifying Elements\nWe can change the **content**, **style** and **attribute** of elements.\n\n```js\n// Changing the inner HTML\nelement.innerHTML = 'New content';\n\n// Changing the style\nelement.style.color = 'blue';\n\n// Changing an attribute\nelement.setAttribute('src', 'newImage.jpg');\n```\n\n#### Creating and Appending Elements\nWe can create new elements and add them to the DOM.\n```js\n// Creating a new element\nlet newElement = document.createElement('div');\nnewElement.innerHTML = 'Hello, world!';\n\n// Appending the new element to an existing element\ndocument.body.appendChild(newElement);\n```\n\n**Reference** : [w3schools](https://www.w3schools.com/js/js_htmldom.asp) |\n[mdn](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction) |\n[geeksforgeeks](https://www.geeksforgeeks.org/dom-document-object-model/)\n\n### Exercise DOM\n#### Create an ordered list\n```js\nlet list = document.getElementById(\"list\")\n\nlet listItems = [\"Mango\", \"Apple\", \"Banana\", \"Orange\"]\n\nlet olList = document.createElement(\"ol\")\n\nlet list1 = document.createElement(\"li\")\nlet list2 = document.createElement(\"li\")\nlet list3 = document.createElement(\"li\")\nlet list4 = document.createElement(\"li\")\n\nlist1.innerText = listItems[0]\nlist2.innerText = listItems[1]\nlist3.innerText = listItems[2]\nlist4.innerText = listItems[3]\n\nolList.appendChild(list1)\nolList.appendChild(list2)\nolList.appendChild(list3)\nolList.appendChild(list4)\n\nlist.appendChild(olList)\n```\n\n\u003cbr/\u003e\n\n## Events\n### What is an Event in JavaScript ?\nEvents in JavaScript are **actions** or **occurrences**\u003cbr/\u003e\nHappen in the browser window, which JavaScript can respond.\u003cbr/\u003e\nThese events can be triggered by user interactions\u003cbr/\u003e\nSuch as `clicking` a button, `typing` in a text field, or `moving` the mouse\u003cbr/\u003e\nAs well as by other actions, like loading a web page or playing a video.\n\nBy handling these events, we can make web pages interactive and responsive to user input.\n\n### Common Events\n#### Mouse Events\n`click`: Fired when an element is clicked.\u003cbr/\u003e\n`dblclick`: Fired when an element is double-clicked.\u003cbr/\u003e\n`mousedown`: Fired when the mouse button is pressed down.\u003cbr/\u003e\n`mouseup`: Fired when the mouse button is released.\u003cbr/\u003e\n`mousemove`: Fired when the mouse pointer is moved.\u003cbr/\u003e\n`mouseover`: Fired when the mouse pointer moves over an element.\u003cbr/\u003e\n`mouseout`: Fired when the mouse pointer moves out of an element.\n\n#### Keyboard Events\n`keydown`: Fired when a key is pressed down.\u003cbr/\u003e\n`keyup`: Fired when a key is released.\u003cbr/\u003e\n`keypress`: Fired when a key is pressed and released.\n\n#### Form Events\n`submit`: Fired when a form is submitted.\u003cbr/\u003e\n`change`: Fired when the value of an element changes.\u003cbr/\u003e\n`focus`: Fired when an element gains focus.\u003cbr/\u003e\n`blur`: Fired when an element loses focus.\n\n#### Document/Window Events\n`load`: Fired when the document or an image is fully loaded.\u003cbr/\u003e\n`resize`: Fired when the window is resized.\u003cbr/\u003e\n`scroll`: Fired when the document view is scrolled.\u003cbr/\u003e\n`unload`: Fired when the user navigates away from the page.\n\n\n#### Clipboard Events\n`copy`: Fired when content is copied.\u003cbr/\u003e\n`cut`: Fired when content is cut.\u003cbr/\u003e\n`paste`: Fired when content is pasted.\n\n### Event Handling\n#### Using `addEventListener`\n\n```js\nlet button = document.getElementById('myButton');\nbutton.addEventListener('click', function() {\n    alert('Button was clicked!');\n});\n```\n\n#### Using HTML Event Attributes\n\n```js\n\u003cbutton id=\"myButton\" onclick=\"alert('Button was clicked!')\"\u003eClick Me\u003c/button\u003e\n```\n\n#### Using DOM Properties\n\n```js\nlet button = document.getElementById('myButton');\nbutton.onclick = function() {\n    alert('Button was clicked!');\n};\n```\n\n**Reference** : [w3schools](https://www.w3schools.com/js/js_events.asp) |\n[mdn](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events) |\n[geeksforgeeks](https://www.geeksforgeeks.org/javascript-events/)\n\n\u003cbr/\u003e\n\n## Math\n### Math Object in JavaScript\nJavaScript provides a built-in Math object that contains properties and methods for performing mathematical operations and calculations.\u003cbr/\u003e\nobject is static, meaning you do not need to create an instance of it to use its methods and properties.\n\n\u003e [!NOTE]\\\n\u003e We can see the list all Math methods by simple logging the Math object in console.\\\n\u003e ```js\n\u003e console.log(Math)\n\u003e ```\n\n#### List of Math method\n**`Math.abs(x)`**\n```js\nlet absoluteValue = Math.abs(-5); // 5\n\n// Returns the absolute value of a number\n```\n\n**`Math.ceil(x)`**\n```js\nlet roundedUp = Math.ceil(4.2); // 5\n\n// Rounds a number upwards to the nearest integer\n```\n\n**`Math.floor(x)`**\n```js\nlet roundedDown = Math.floor(4.8); // 4\n\n// Rounds a number downwards to the nearest integer\n```\n\n**`Math.round(x)`**\n```js\nlet rounded = Math.round(4.5); // 5\n\n// Rounds a number to the nearest integer.\n```\n\n**`Math.max(x, y, ...)`**\n```js\nlet maxNumber = Math.max(1, 2, 3, 4); // 4\n\n// Returns the largest of the zero or more numbers given as input parameters\n```\n\n**`Math.min(x, y, ...)`**\n```js\nlet minNumber = Math.min(1, 2, 3, 4); // 1\n\n// Returns the smallest of the zero or more numbers given as input parameters\n```\n\n**`Math.random()`**\n```js\nlet randomNumber = Math.random(); // e.g., 0.123456789\n\n// Returns a pseudo-random number between 0 (inclusive) and 1 (exclusive)\n```\n\n**`Math.sqrt(x)`**\n```js\nlet squareRoot = Math.sqrt(16); // 4\n\n// Returns the square root of a number\n```\n\n**`Math.pow(base, exponent)`**\n```js\nlet power = Math.pow(2, 3); // 8\n\n// Returns the base to the exponent power (i.e., base^exponent)\n```\n\n**`Math.trunc(x)`**\n```js\nlet truncated = Math.trunc(4.9); // 4\n\n// Returns the integer part of a number by removing any fractional digits\n```\n\n**`Math.sign(x)`**\n```js\nlet sign = Math.sign(-5); // -1\n\n// Returns the sign of a number, indicating whether the number is positive, negative, or zero\n```\n\n**`Math.sin(x), Math.cos(x), Math.tan(x)`**\n```js\nlet sine = Math.sin(Math.PI / 2); // 1\nlet cosine = Math.cos(0); // 1\nlet tangent = Math.tan(Math.PI / 4); // 1\n\n// Return the sine, cosine, and tangent of a number (the argument is in radians)\n```\n\n**`Math.log(x), Math.log10(x)`**\n```js\nlet naturalLog = Math.log(1); // 0\nlet logBase10 = Math.log10(10); // 1\n\n// Returns the natural logarithm (base e) and the logarithm base 10 of a number\n```\n\n**Reference** : [mdn](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math) |\n[w3schools](https://www.w3schools.com/js/js_math.asp)\n\n\u003cbr/\u003e\n\n## Date\n### What is Date object ?\nIn JavaScript, We have a built-in `Date` object.\u003cbr/\u003e\nWe use it to get time.\n\n### Methods to access date\nWe can create a new instance using date object as\n```js\nlet date = new Date();\n\nconsole.log(date);\n```\nWe can use the above object to extract any particular value\n```js\n// for getting year\nlet year = date.getFullYear();\n\nconsole.log(year);\n\n// for getting date\nlet today = date.getDate();\n\nconsole.log(today);\n\n// for getting month\nlet month = date.getMonth() + 1;\n\nconsole.log(month);\n```\n\u003e [!NOTE]\\\n\u003e `Date()` object uses an array of months as\\\n\u003e [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"];\\\n\u003e Whenever we use `getMonth()` method it returns the index value of the month.\\\n\u003e To get the expected month number just **increment** it by one (`month += 1`) before using it.\n```js\n// for getting day\nlet day = date.getDay() + 1;\n\nconsole.log(day);\n```\n\u003e [!NOTE]\\\n\u003e As months, `Date()` object also has an array for days\\\n\u003e [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"];\\\n\u003e We need to **increment** it by one (`day += 1`) before using it.\n```js\n// for getting hours\nlet hours = date.getHours();\n\nconsole.log(hours);\n\n// for getting minutes\nlet minutes = date.getgetMinutes();\n\nconsole.log(minutes);\n\n// for getting seconds\nlet seconds = date.getSeconds();\n\nconsole.log(seconds);\n\n// for getting mili-seconds\nlet miliseconds = date.getMilliseconds();\n\nconsole.log(miliseconds);\n\n// for getting localeString\nlet localeString = now.toLocaleString();\n\nconsole.log(localeString);\n\n// for getting localeDateString\nlet localeDateString = now.toLocaleDateString();\n\nconsole.log(localeDateString);\n\n// for getting localeTimeString\nlet localeTimeString = now.toLocaleTimeString();\n\nconsole.log(localeTimeString);\n```\n\n**Reference** : [mdn](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) |\n[w3schools](https://www.w3schools.com/jsref/jsref_obj_date.asp)\n\n\u003cbr/\u003e\n\n## Contribute! 🤝\nThis repository is open for collaboration, and your contributions are welcome! 🥰\u003cbr/\u003e\nIf you spot any error, have a suggestion, or want to add new content, feel free to submit a pull request.\u003cbr/\u003e\nLet's make this guide a vibrant and up-to-date resource for the entire **JavaScript Aspirants**\n\n**Fork the Repository**\u003cbr/\u003e\nFork this repository to contribute and become a part of JavaScript-Collection\n\n### [Fork: JavaScript BrainStorming⚡](https://github.com/Ninja-Vikash/JavaScript-Collection/fork) 👈(Click here)\n\n**Clone repository**\u003cbr/\u003e\nClone your forked repository to your local machine using the `git clone` command.\u003cbr/\u003e\nReplace `username` with your GitHub username.\n```bash\ngit clone https://github.com/username/JavaScript-BrainStorming.git\n```\n\nCreate a new branch for your ideas named it as `new-idea`\u003cbr/\u003e\nMake changes on your branch and push your changes using these commands.\n```bash\ngit checkout -b new-idea\n\ngit add .\ngit commit -m \"Brief description of your changes\"\n\ngit push origin new-idea\n```\n\n#### Happy Coding 💖\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fninja-vikash%2Fjavascript-brainstorming","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fninja-vikash%2Fjavascript-brainstorming","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fninja-vikash%2Fjavascript-brainstorming/lists"}