forked from 10-6-pursuit/reference-types-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
40 lines (36 loc) · 1.35 KB
/
Copy pathindex.js
File metadata and controls
40 lines (36 loc) · 1.35 KB
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
/**
* Adds a new store to the very end of the list.
* @param {Object[]]} stores - An array of store objects.
* @param {Object} store - An object representing a single store. See the instructions for details on its shape.
* @returns {Object[]} The same `stores` array that was inputted.
*/
function addNewStore(stores, store) {
stores.push(store);
return stores;
}
/**
* Removes a store object at the given position.
* @param {Object[]]} stores - An array of store objects.
* @param {number} index - A number representing the index of the store to be removed from the array.
* @returns {Object[]} The same `stores` array that was inputted.
*/
function removeStoreAtPosition(stores, index) {
stores.splice(index,1);
return stores;
}
/**;
* Creates a duplicate of the `store` object. No references should be shared between the inputted `store` and the result.
* @param {Object} store - An object representing a single store. See the instructions for details on its shape.
* @returns {Object} The duplicated store object. This should not be the same as the store that was inputted.
*/
function duplicateStore(store) {
let duplicateStore = {...store};
duplicateStore.boardGames=[...store.boardGames]
duplicateStore.address={...store.address};
return duplicateStore;
}
module.exports = {
addNewStore,
removeStoreAtPosition,
duplicateStore,
};