You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/concept/train-driver/.docs/instructions.md
+27-43Lines changed: 27 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,88 +2,76 @@
2
2
3
3
Your friend is a train driver and has to drive cargo trains between cities.
4
4
Although your friend isn't amazing with handling the computers and would like some help with it.
5
-
Your friend would like your help organizing the train and correcting the mistakes in the data.
5
+
Your friend would like your help organizing the train and correcting mistakes in the data.
6
6
7
7
8
8
```exercism/note
9
-
To practice, use a for the rest or spread to solve each of the tasks below.
9
+
To practice, use the rest or spread operator to solve each of the tasks below.
10
10
```
11
11
12
-
## 1. Convert the data to an array
12
+
## 1. Create a list of all wagons
13
13
14
-
Your friend has been keeping track of how much each wagon weighs. Although they are not sure how many wagons and would like the data to be returned as an array.
14
+
Your friend has been keeping track of eachs wagon identifer. Although they are not sure how many wagons and would like the data to be returned as an array.
15
15
16
-
```exercism/note
17
-
18
-
Implement a function `getListOfWagons` that accepts an unknown amount of whole numbers that contains the weight of each wagon.
19
-
It should return an array of all the wagon weights.
20
-
21
-
```
16
+
Implement a function `getListOfWagons` that accepts an unknown amount of possitve whole numbers that contains the id of each wagon.
17
+
It should return an array of all the wagon ids.
22
18
23
19
```javascript
24
-
getListOfWagons(5, 7, 12, 3, 14, 8, 3);
25
-
// => [5, 7, 12, 3, 14, 8, 3]
20
+
getListOfWagons(1, 7, 12, 3, 14, 8, 5);
21
+
// => [1, 7, 12, 3, 14, 8, 3]
26
22
```
27
23
28
24
## 2. Move the first two elements to the end of the array
29
25
30
-
Now that you got a general feel for handling your friend's data. Your friend has noticed that the first two days' values are not in the correct place.
31
-
Your friend would like you to move the first two days' value to the end of the array.
32
-
33
-
```exercism/note
26
+
Now that you got a general feel for handling your friend's data.
27
+
The train id system works by the locomotive having id one and the rest of the wagons geting a random id.
28
+
You friend had to connect two new wagons to the train and forgot to update the id system.
29
+
Now the first two wagons in the array has to be moved to the back of the train.
30
+
Your friend would like you to move the first two wagons to the end of the array.
34
31
35
-
Implement a function `fixListOfWagons` that accepts an array of the weight of each wagon.
32
+
Implement a function `fixListOfWagons` that accepts an array of the id of each wagon.
36
33
It returns an array where the 2 first elements are moved to the end of the array.
37
34
38
-
```
39
-
40
35
```javascript
41
-
eachWagonsWieght = [2, 5, 0, 7, 4, 0, 1, 3, 1];
36
+
eachWagonsWieght = [2, 5, 1, 7, 4, 12, 6, 3, 13];
42
37
fixListOfWagons(eachWagonsWieght);
43
-
// => [0, 7, 4, 0, 1, 3, 1, 2, 5]
38
+
// => [1, 7, 4, 12, 6, 3, 13, 2, 5]
44
39
```
45
40
46
41
## 3. Add missing values
47
42
48
-
Your friend realized that all data wasn't added and found another array which contains the missing values.
43
+
Your friend realized that all data wasn't added and found another array which contains the missing wagons.
49
44
Your friend would like you to add the missing values to the array.
50
-
All they can remember is that the missing values should be placed after the first element in the array.
51
-
52
-
53
-
```exercism/note
45
+
All they can remember is that the missing values should be placed after the locomotive in the array.
54
46
55
-
Given this new information, write a function called `CorrectListOfWagons` that takes two arrays which have the values of the weight of each wagon as an argument.
47
+
Given this new information, write a function called `CorrectListOfWagons` that takes two arrays which have the id of of each wagon as an argument.
56
48
The second array should be added after the first element of the first array.
0 commit comments