-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8389cb5
commit af1552e
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Array Exercise Questions | ||
|
||
### Easy: | ||
|
||
1. **Question:** Given an array `numbers`, how do you add a new element `5` to the end of the array? | ||
2. **Question:** How can you check if an array `fruits` contains the value `"apple"`? | ||
3. **Question:** What method can you use to remove the last element from an array `colors`? | ||
4. **Question:** How do you find the number of elements in an array `grades`? | ||
5. **Question:** Given an array `words`, how can you join all its elements into a single string separated by commas? | ||
6. **Question:**: Given an array fruits, how do you add a new element "banana" to the beginning of the array? | ||
7. **Question:**: How can you check if an array numbers is empty (contains no elements)? | ||
8. **Question:**: What method can you use to remove the first element from an array animals? | ||
9. **Question:**: How do you find the largest number in an array scores? | ||
10. **Question:**: Given an array names, how can you add multiple names, "Alice" and "Bob", to the end of the array in one step? | ||
|
||
### Medium: | ||
|
||
11. **Question:** Write a function that takes an array of numbers and returns the sum of all the positive numbers in the array. | ||
12. **Question:** Given an array `names`, how can you create a new array containing only the names that start with the letter `"A"`? | ||
13. **Question:** How do you reverse the order of elements in an array `characters`? | ||
14. **Question:** Write a function that takes an array of strings and returns a new array with the strings sorted in alphabetical order. | ||
15. **Question:** Given an array `numbers`, how can you find the index of the first occurrence of the number `7`? | ||
16. **Question:**: Write a function that takes an array of strings and returns the longest string in the array. | ||
17. **Question:**: Given two arrays, arr1 and arr2, how can you combine them into a single array combinedArray? | ||
18. **Question:**: How do you remove all duplicate values from an array values? | ||
19. **Question:**: Write a function that takes an array of objects representing people with name, age, and city properties and returns an array of just the names. | ||
20. **Question:**: Given an array numbers, how do you find the sum of all even numbers in the array? | ||
|
||
### Hard: | ||
|
||
21. **Question:** Write a function that takes an array of numbers and returns a new array with only the unique values (no duplicates). | ||
22. **Question:** How can you implement a custom `map` function that works like the built-in `Array.prototype.map`? | ||
23. **Question:** Write a function that takes two arrays, `arr1` and `arr2`, and returns a new array containing the elements that appear in both arrays (intersection). | ||
24. **Question:** Given an array of objects `people`, how can you find the person with the highest age? | ||
25. **Question:** Write a function that takes an array of numbers and returns the median (middle value) of the numbers. | ||
26. **Question:** Write a function that takes an array of objects representing books with title, author, and publicationYear properties and returns an array of books published before the year 2000. | ||
27. **Question:** How can you implement a custom filter function that works like the built-in Array.prototype.filter? | ||
28. **Question:** Write a function that takes an array of numbers and returns a new array with the numbers squared. | ||
29. **Question:** Given two sorted arrays, arr1 and arr2, write a function to merge them into a single sorted array. | ||
30. **Question:** Write a function that takes an array of words and returns an object that counts how many times each word appears in the array. |