Skip to content

Commit 7ee315a

Browse files
Fix typos and missing import (#2656)
* Fix typos and missing import * More clean-up
1 parent 921d8e5 commit 7ee315a

File tree

5 files changed

+77
-52
lines changed

5 files changed

+77
-52
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
// because of how whitespace is (not) rendered.
88
65
99
]
10-
}
10+
},
11+
"cSpell.words": ["reorderd"]
1112
}

exercises/concept/train-driver/.docs/instructions.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
# Instructions
22

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.
46

57
```exercism/note
68
To practice, use the rest or spread operator to solve each of the tasks below.
79
```
810

911
## 1. Create a list of all wagons
1012

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`.
1215

1316
Implement a function `getListOfWagons` that accepts an arbitrary number of wagon IDs which are the IDs of each wagon.
1417
Each ID will be a positive integer.
@@ -21,14 +24,16 @@ getListOfWagons(1, 7, 12, 3, 14, 8, 5);
2124

2225
## 2. Move the first two elements to the end of the array
2326

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**.
2529

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.
2732

2833
Linus would be really grateful to you for fixing their mistakes.
2934

3035
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.
3237

3338
```javascript
3439
eachWagonsID = [2, 5, 1, 7, 4, 12, 6, 3, 13];
@@ -43,7 +48,7 @@ Uh-oh. some wagons seem to have gone missing.
4348
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`.
4449
All they can remember is that the missing values should be placed directly after the designated locomotive.
4550

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.
4752
The wagon IDs of the second `array` should be added into the first `array` directly after the locomotive (ID 1).
4853

4954
```javascript
@@ -59,7 +64,7 @@ Now that all the wagon data is correct, your friend would like you to update the
5964
Initial routing information has been constructed as an `object`, and you friend would like you to update it with the additions provided.
6065
Every route requires slightly different information, so your friend would really prefer a generic solution.
6166

62-
Implement a function extendRouteInformation that accepts two `objects`.
67+
Implement a function `extendRouteInformation` that accepts two `objects`.
6368
The first `object` contains which cities the train route moves between.
6469

6570
The second `object` contains other routing details such as train speed or length.
@@ -81,7 +86,7 @@ extendRouteInformation(route, moreRouteInformation);
8186
Your friend has noticed that they don't need the arrival time in the routing information.
8287
Therefore your friend would like you to separate the arrival time from the routing information.
8388

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.
8590
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.
8691

8792
```javascript

exercises/concept/train-driver/.meta/exemplar.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,55 @@
55
// implementing this exercise.
66

77
/**
8-
* Return each Wagons id in form of an array.
8+
* Return each wagon's id in form of an array.
99
*
10-
* @param {number[]} eachWagonsID
11-
* @returns {number[]} each Wagons Wiegth
10+
* @param {number[]} ids
11+
* @returns {number[]} wagon ids
1212
*/
13-
export function getListOfWagons(...eachWagonsID) {
14-
return eachWagonsID;
13+
export function getListOfWagons(...ids) {
14+
return ids;
1515
}
1616

1717
/**
1818
* Reorder the array of wagons by moving the first 2 wagons to the end of the array.
1919
*
20-
* @param {number[]} eachWagonsID
21-
* @returns {number[]} reorderd list of wagons
20+
* @param {number[]} ids
21+
* @returns {number[]} reordered list of wagons
2222
*/
23-
export function fixListOfWagons(eachWagonsID) {
24-
const [first, second, ...rest] = eachWagonsID;
23+
export function fixListOfWagons([first, second, ...rest]) {
2524
return [...rest, first, second];
2625
}
2726

2827
/**
2928
* Fixes the array of wagons by inserting an array of wagons after the first element in eachWagonsID.
3029
*
31-
* @param {number[]} eachWagonsID
30+
* @param {number[]} ids
3231
* @param {number[]} missingWagons
3332
* @returns {number[]} corrected list of wagons
3433
*/
35-
export function correctListOfWagons(eachWagonsID, missingWagons) {
36-
const [first, ...rest] = eachWagonsID;
34+
export function correctListOfWagons([first, ...rest], missingWagons) {
3735
return [first, ...missingWagons, ...rest];
3836
}
3937

4038
/**
4139
* Extend route information by adding another object
4240
*
43-
* @param {Record<string, string>} route
44-
* @param {Record<string, string>} moreRouteInformation
41+
* @param {Record<string, string>} information
42+
* @param {Record<string, string>} additional
4543
* @returns {Record<string, string>} extended route information
4644
*/
47-
export function extendRouteInformation(route, moreRouteInformation) {
48-
return { ...route, ...moreRouteInformation };
45+
export function extendRouteInformation(information, additional) {
46+
return { ...information, ...additional };
4947
}
5048

5149
/**
5250
* Separate arrival time from the route information object
5351
*
54-
* @param {Record<string, string>} route
52+
* @param {Record<string, string>} information
5553
* @returns {[string, Record<string, string>]} array with arrival time and object without arrival time
5654
*/
57-
export function separateTimeOfArrival(route) {
58-
const { timeOfArrival, ...rest } = route;
55+
export function separateTimeOfArrival(information) {
56+
const { timeOfArrival, ...rest } = information;
57+
5958
return [timeOfArrival, rest];
6059
}

exercises/concept/train-driver/train-driver.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,53 @@
55
// implementing this exercise.
66

77
/**
8-
* Return each Wagons id in form of an array.
8+
* Return each wagon's id in form of an array.
99
*
10-
* @param {number[]} eachWagonsID
11-
* @returns {number[]} each Wagons Wiegth
10+
* @param {number[]} ids
11+
* @returns {number[]} wagon ids
1212
*/
13-
export function getListOfWagons(eachWagonsID) {
13+
export function getListOfWagons(a, b, c, d, e, f, g, h, i, j, k, l, m, n) {
1414
throw new Error('Please implement the getListOfWagons function');
1515
}
1616

1717
/**
1818
* Reorder the array of wagons by moving the first 2 wagons to the end of the array.
1919
*
20-
* @param {number[]} eachWagonsID
20+
* @param {number[]} ids
2121
* @returns {number[]} reorderd list of wagons
2222
*/
23-
export function fixListOfWagons(eachWagonsID) {
23+
export function fixListOfWagons(ids) {
2424
throw new Error('Please implement the fixListOfWagons function');
2525
}
2626

2727
/**
2828
* Fixes the array of wagons by inserting an array of wagons after the first element in eachWagonsID.
2929
*
30-
* @param {number[]} eachWagonsID
30+
* @param {number[]} ids
3131
* @param {number[]} missingWagons
3232
* @returns {number[]} corrected list of wagons
3333
*/
34-
export function correctListOfWagons(eachWagonsID, missingWagons) {
34+
export function correctListOfWagons(ids, missingWagons) {
3535
throw new Error('Please implement the correctListOfWagons function');
3636
}
3737

3838
/**
3939
* Extend route information by adding another object
4040
*
41-
* @param {Record<string, string>} route
42-
* @param {Record<string, string>} moreRouteInformation
41+
* @param {Record<string, string>} information
42+
* @param {Record<string, string>} additional
4343
* @returns {Record<string, string>} extended route information
4444
*/
45-
export function extendRouteInformation(route, moreRouteInformation) {
45+
export function extendRouteInformation(information, additional) {
4646
throw new Error('Please implement the extendRouteInformation function');
4747
}
4848

4949
/**
5050
* Separate arrival time from the route information object
5151
*
52-
* @param {Record<string, string>} route
52+
* @param {Record<string, string>} information
5353
* @returns {[string, Record<string, string>]} array with arrival time and object without arrival time
5454
*/
55-
export function separateTimeOfArrival(route) {
55+
export function separateTimeOfArrival(information) {
5656
throw new Error('Please implement the separateTimeOfArrival function');
5757
}

0 commit comments

Comments
 (0)