-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy patharrays.js
82 lines (70 loc) · 2.35 KB
/
arrays.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Step 1:
// Write a createGroceries function that returns an array with 6 groceries items
function createGroceries() {
// write your code here...
}
// Step 2:
// Write a getSecondGroceryItem function that returns the second grocery item from `groceries` argument
function getSecondGroceryItem(groceries) {
// write your code here...
}
// Step 3:
// Write a getGroceriesCount that returns the length of the `groceries` argument
function getGroceriesCount(groceries) {
// write your code here...
}
// Step 4:
// Write a getLastGroceryItem function that returns the last grocery item from `groceries` argument
function getLastGroceryItem(groceries) {
// write your code here...
}
// Step 5:
// Write a removeLastGroceryItem function that removes the last grocery item and return it
function removeLastGroceryItem(groceries) {
// write your code here...
}
// Step 6:
// Write a addNewGroceries function that adds two new and different grocery items to the end of the groceries argument
// and returns the modified array
function addNewGroceries(groceries, itemOne, itemTwo) {
// write your code here...
}
// Step 7:
// Write a getFirstThreeGroceryItems function that returns a new array that contains the first three grocery items
function getFirstThreeGroceryItems(groceries) {
// write your code here...
}
// 🌶️🌶️🌶️ **Challenge**
// Step 1:
// Write a deleteThirdItem function that deletes the third item from the groceries argument
// and returns the modified groceries list
function deleteThirdItem(groceries) {
// write your code here...
}
// Step 2:
// Write a insertItemAtBeginning function that inserts a new grocery item at the beginning of the groceries argument
// and returns the modified groceries array
function insertItemAtBeginning(groceries, item) {
// write your code here...
}
// Step 3:
// Write a replaceFirstTwoItems function that replace the first two elements with 'ketchup' and 'chili'
// and return the modified groceries array
function replaceFirstTwoItems(groceries) {
// write your code here...
}
// DO NOT CHANGE THE LINE OF CODE BELOW
const groceries = createGroceries();
module.exports = {
groceries,
createGroceries,
getSecondGroceryItem,
getGroceriesCount,
getLastGroceryItem,
removeLastGroceryItem,
addNewGroceries,
getFirstThreeGroceryItems,
deleteThirdItem,
insertItemAtBeginning,
replaceFirstTwoItems,
};