Skip to content

Commit 55220cc

Browse files
committed
fix
1 parent 6a3ca84 commit 55220cc

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

1-js/05-data-types/05-array-methods/8-sort-objects/solution.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
```js run no-beautify
22
function sortByName(arr) {
3-
arr.sort((a, b) => b.name > a.name ? 1 : -1);
3+
arr.sort((a, b) => a.age > b.age ? 1 : -1);
44
}
55

66
let john = { name: "John", age: 25 };
@@ -12,6 +12,6 @@ let arr = [ john, pete, mary ];
1212
sortByName(arr);
1313

1414
// now sorted is: [john, mary, pete]
15-
alert(arr[1].name); // Mary
15+
alert(arr[0].name); // John
16+
alert(arr[2].name); // Pete
1617
```
17-

1-js/05-data-types/05-array-methods/8-sort-objects/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ importance: 5
44

55
# Sort objects
66

7-
Write the function `sortByName(users)` that gets an array of objects with property `name` and sorts it.
7+
Write the function `sortByName(users)` that gets an array of objects with the `age` property and sorts them by `age`.
88

99
For instance:
1010

@@ -18,6 +18,6 @@ let arr = [ john, pete, mary ];
1818
sortByName(arr);
1919

2020
// now: [john, mary, pete]
21-
alert(arr[1].name); // Mary
21+
alert(arr[0].name); // Mary
22+
alert(arr[2].name); // Pete
2223
```
23-

0 commit comments

Comments
 (0)