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
+13-8Lines changed: 13 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,17 @@
1
1
# Instructions
2
2
3
-
Your friend Linus is a train driver who drives cargo trains between cities. Although they are amazing at handling trains, they are not amazing at handling logistics or computers. They would like to enlist your programming help organizing train details and correcting mistakes in route data.
3
+
Your friend Linus is a train driver who drives cargo trains between cities.
4
+
Although they are amazing at handling trains, they are not amazing at handling logistics or computers.
5
+
They would like to enlist your programming help organizing train details and correcting mistakes in route data.
4
6
5
7
```exercism/note
6
8
To practice, use the rest or spread operator to solve each of the tasks below.
7
9
```
8
10
9
11
## 1. Create a list of all wagons
10
12
11
-
Your friend has been keeping track of each wagon identifier (ID), but they are never sure how many wagons the system is going to have to process at any given time. It would be much easier for the rest of the logistics program to have this data packaged into a unified `array`.
13
+
Your friend has been keeping track of each wagon identifier (ID), but they are never sure how many wagons the system is going to have to process at any given time.
14
+
It would be much easier for the rest of the logistics program to have this data packaged into a unified `array`.
12
15
13
16
Implement a function `getListOfWagons` that accepts an arbitrary number of wagon IDs which are the IDs of each wagon.
## 2. Move the first two elements to the end of the array
23
26
24
-
At this point, you are starting to get a feel for the data and how it's used in the logistics program. The ID system always assigns the locomotive an ID of **1**, with the remainder of the wagons in the train assigned a randomly chosen ID greater than **1**.
27
+
At this point, you are starting to get a feel for the data and how it's used in the logistics program.
28
+
The ID system always assigns the locomotive an ID of **1**, with the remainder of the wagons in the train assigned a randomly chosen ID greater than **1**.
25
29
26
-
Your friend had to connect two new wagons to the train and forgot to update the system! Now, the first two wagons in the train `array` have to be moved to the end, or everything will be out of order.
30
+
Your friend had to connect two new wagons to the train and forgot to update the system!
31
+
Now, the first two wagons in the train `array` have to be moved to the end, or everything will be out of order.
27
32
28
33
Linus would be really grateful to you for fixing their mistakes.
29
34
30
35
Implement a function `fixListOfWagons` that accepts an array of the id of each wagon.
31
-
It `return` an `array` where the 2 first elements repositioned to the end of the `array` so that the locomotive can be in the front.
36
+
It `return`s an `array` where the 2 first elements repositioned to the end of the `array` so that the locomotive can be in the front.
32
37
33
38
```javascript
34
39
eachWagonsID = [2, 5, 1, 7, 4, 12, 6, 3, 13];
@@ -43,7 +48,7 @@ Uh-oh. some wagons seem to have gone missing.
43
48
Fortunately, your friend just found another `array` which appears to contain the missing wagon IDs, and would like you to add them into the main wagon ID `array`.
44
49
All they can remember is that the missing values should be placed directly after the designated locomotive.
45
50
46
-
Given this new information, write a function called `CorrectListOfWagons` that takes two arrays which have the IDs of each wagon as the arguments.
51
+
Given this new information, write a function called `correctListOfWagons` that takes two arrays which have the IDs of each wagon as the arguments.
47
52
The wagon IDs of the second `array` should be added into the first `array` directly after the locomotive (ID 1).
48
53
49
54
```javascript
@@ -59,7 +64,7 @@ Now that all the wagon data is correct, your friend would like you to update the
59
64
Initial routing information has been constructed as an `object`, and you friend would like you to update it with the additions provided.
60
65
Every route requires slightly different information, so your friend would really prefer a generic solution.
61
66
62
-
Implement a function extendRouteInformation that accepts two `objects`.
67
+
Implement a function `extendRouteInformation` that accepts two `objects`.
63
68
The first `object` contains which cities the train route moves between.
64
69
65
70
The second `object` contains other routing details such as train speed or length.
Your friend has noticed that they don't need the arrival time in the routing information.
82
87
Therefore your friend would like you to separate the arrival time from the routing information.
83
88
84
-
Implement a function `separateArrivalTime` that accepts an object with the routing information.
89
+
Implement a function `separateTimeOfArrival` that accepts an object with the routing information.
85
90
The function should return an array there the first element of the array is the arrival time and the second element is an object with the routing information without arrival time.
0 commit comments