Skip to content

Commit 1b05719

Browse files
committed
Updated tasks
1 parent f466fa3 commit 1b05719

File tree

2 files changed

+89
-2
lines changed

2 files changed

+89
-2
lines changed

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
*Important Note:
3+
© 2024 tapaScript. Feel free to use the content of the file to solve questions, learn things. Sharing content of this file outside of this repository requires permission from the [author](https://github.com/atapas). Also the content from this repository must not be used for any commercial digital or printed product without the author's consent. Please reach out to [Tapas Adhikary](https://www.linkedin.com/in/tapasadhikary/) for any questions.
4+
*/
5+
16
"use strict";
27

38
// How to Create an Array in JavaScript

task.md

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
This file contains the tasks that you need to perform to practise the concepts learned from the course. Please spend some time practising; otherwise, all the time you spend learning something will be a complete waste.
44

5-
> Please Note: These tasks are for your practice. If you are stuck, go back to the videos and get the clarifications. If you are still stuck, feel free to start a conversation on [tapaScript Discord](https://discord.gg/HHwdF8r28m).
6-
5+
## Important Note
6+
**`© 2024 tapaScript`: Feel free to use the content of the file to solve questions, learn things. Sharing content of this file outside of this repository requires permission from the [author](https://github.com/atapas). Also the content from this repository must not be used for any commercial digital or printed product without the author's consent. Please reach out to [Tapas Adhikary](https://www.linkedin.com/in/tapasadhikary/) for any questions.**
77

8+
## Questions
9+
> Please Note: These tasks are for your practice. If you are stuck, go back to the videos and get the clarifications. If you are still stuck, feel free to start a conversation on [tapaScript Discord](https://discord.gg/HHwdF8r28m).
810
911
- [ ] **T-001**: Create an array of 5 elements using the Array Constructor.
1012
- [ ] **T-002**: Create an array of 3 empty slots.
@@ -26,3 +28,83 @@ This file contains the tasks that you need to perform to practise the concepts l
2628
- [ ] **T-018**: Can you give examples of sparse and dense arrays?
2729
- [ ] **T-019**: Give a practical usages of the .fill() method
2830
- [ ] **T-020**: How to convert an array to a string?
31+
32+
33+
> Consider these input arrays for question **T-21** to **T-48**
34+
35+
- `employees array`: An array of emplyees working in a department.
36+
37+
```js
38+
const employees = [
39+
{ id: 1, name: "Alice", departmentId: 1, salary: 5000 },
40+
{ id: 2, name: "Bob", departmentId: 2, salary: 7000 },
41+
{ id: 3, name: "Charlie", departmentId: 3, salary: 4500 },
42+
{ id: 4, name: "Diana", departmentId: 1, salary: 5500 },
43+
{ id: 5, name: "Edward", departmentId: 2, salary: 8000 },
44+
{ id: 6, name: "Fiona", departmentId: 4, salary: 6000 },
45+
{ id: 7, name: "George", departmentId: 3, salary: 5200 },
46+
{ id: 8, name: "Helen", departmentId: 4, salary: 7200 },
47+
{ id: 9, name: "Ian", departmentId: 2, salary: 4800 },
48+
{ id: 10, name: "Jane", departmentId: 1, salary: 5100 },
49+
];
50+
```
51+
52+
- `departments array`: An array of departments where emplyees work.
53+
54+
```js
55+
const departments = [
56+
{ id: 1, name: "HR" },
57+
{ id: 2, name: "Engineering" },
58+
{ id: 3, name: "Marketing" },
59+
{ id: 4, name: "Sales" },
60+
];
61+
```
62+
63+
- [ ] **T-021**: Can you filter employees who work in the "Engineering" department?
64+
- [ ] **T-022**: Create a new array that combines employee names and department names in the format: "Alice (HR)".
65+
- [ ] **T-023**: Find the highest salary among employees.
66+
- [ ] **T-024**: Check if there is at least one employee in the "Sales" department.
67+
- [ ] **T-025**: Write a function to filter employees earning more than 6000.
68+
- [ ] **T-026**: Create an array of employee names only.
69+
- [ ] **T-027**: Calculate the total salary of all employees using
70+
- [ ] **T-028**: Is there any employee earning less than 5000?
71+
- [ ] **T-029**: Find the first employee who earns exactly 5100.
72+
- [ ] **T-030**: Find the last employee in the "HR" department.
73+
- [ ] **T-031**: Find the first employee in the "Marketing" department.
74+
- [ ] **T-032**: Check if all employees earn more than 4000.
75+
- [ ] **T-033**: Find the last employee in the "HR" department.
76+
- [ ] **T-034**: Verify if all employees belong to a department listed in the departments array.
77+
- [ ] **T-035**: Log each employee's name and department name to the console.
78+
- [ ] **T-036**: Extract all employee skill names into a single array.
79+
- [ ] **T-037**: Increment each employee's salary by 10%
80+
- [ ] **T-038**: Assume each employee can have multiple skills. Create an array of employee skills and flatten them. Example: [{name: "Alice", skills: ["Excel", "Management"]}, ...].
81+
- [ ] **T-039**: Find the total salary of all employees working in the "Engineering" department.
82+
- [ ] **T-040**: Check if there is any department where all employees earn more than 5000.
83+
- [ ] **T-041**: Assume each employee has a projects array (e.g., { id: 1, name: "Alice", projects: ["Project A", "Project B"] }).
84+
Find the total number of unique projects being handled across all employees.
85+
- [ ] **T-042**: For each employee, find their department name and return an array of employee names with their department names.
86+
- [ ] **T-043**: Get a list of names of employees earning more than 6000.
87+
- [ ] **T-044**: Write a for-of loop to print the names of all employees from the employees array.
88+
- [ ] **T-045**: Using a for-of loop, print the names of employees earning more than 5000.
89+
- [ ] **T-046**: Modify the for-of loop to destructure each employee object and log their name and salary.
90+
- [ ] **T-047**: Write a for-of loop to match employees with their departments and print the results.
91+
- [ ] **T-048**: Use Array.prototype.entries() with a for-of loop to print the index and name of each employee.
92+
93+
94+
- [ ] **T-049**: Given the array-like object below, access the second element and log it:
95+
```js
96+
const arrayLike = { 0: "First", 1: "Second", length: 2 };
97+
```
98+
- [ ] **T-050**: Write a function that takes a variable number of arguments and converts the arguments object into a real array using Array.from.
99+
- [ ] **T-051**: Write a snippet to select all div elements on a webpage (using document.querySelectorAll) and convert the resulting NodeList into an array.
100+
- [ ] **T-052**: Merge these two arrays into a single array:
101+
```js
102+
const arr1 = [1, 2];
103+
const arr2 = [3, 4];
104+
```
105+
- [ ] **T-053**: Create an array of n duplicate values using Array.from. Input: Create an array with 5 "A" values. Output: ["A", "A", "A", "A", "A"]
106+
- [ ] **T-054**: Use Array.from to convert a string like "Hello" into an array of characters.
107+
108+
109+
110+

0 commit comments

Comments
 (0)