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
"description": "Set `var myBest` to your scores, excluding any grades that are\"D\" or \"F\".",
36
+
"description": "Write a filter condition called `isGoodGrade` that will filter out any\"D\" or \"F\" grades.",
36
37
"tests": [
37
38
"1/01/03-filter"
38
39
],
39
40
"actions": [
40
-
"insert('var myBest = myData.filter // filter out \"D\"'s and \"F\"'s here\n')"
41
+
"insert('// return true if student \"grade\" is not a \"D\" or \"F\"\nfunction isGoodGrade() {\n\n}\n')"
42
+
]
43
+
},
44
+
{
45
+
"description": "Set `var myBest` to your scores, excluding any grades that are \"D\" or \"F\".",
46
+
"tests": [
47
+
"1/01/04-filter"
48
+
],
49
+
"actions": [
50
+
"insert('// filter out \"D\"'s and \"F\"'s here\nvar myBest = myData.filter();\n\n')"
41
51
]
42
52
}
43
53
]
44
54
},
45
55
{
46
56
"title": "Sort",
47
-
"description": "Array -> sorted Array"
57
+
"description": "Array -> sorted Array",
58
+
"explanation": "Your grades are filtered down to your name and good scores - but wouldn't it be better if your best grades were shown at the top? Besides, your parents rarely read all the way down to the bottom.\n\nWe can use the array method `sort` to arrange our data. Let's see how it works.",
59
+
"tasks": [
60
+
{
61
+
"description": "Write a sort condition function called `sortByScore` that can sort your data by score.",
62
+
"tests": [
63
+
"1/02/01-sort"
64
+
],
65
+
"actions": [
66
+
"open('02-sort.js')",
67
+
"set('function sortByScore(a, b) {\n // it should return -1 a's score is bigger than b's\n\n // it should return 1 if a's score is less than b's\n\n // it should return 0 if a has the same score as b\n\n}\n')"
Your grades are filtered down to your name and good scores - but wouldn't it be better if your best grades were shown at the top? Besides, your parents rarely read all the way down to the bottom.
5
+
6
+
We can use the array method `sort` to arrange our data. Let's see how it works.
7
+
8
+
+ Write a sort condition function called `sortByScore` that can sort your data by score.
9
+
@test('1/02/01-sort')
10
+
@action(open('02-sort.js'))
11
+
@action(set(
12
+
```
13
+
function sortByScore(a, b) {
14
+
// it should return -1 a's score is bigger than b's
15
+
16
+
// it should return 1 if a's score is less than b's
17
+
18
+
// it should return 0 if a has the same score as b
0 commit comments