Skip to content

Commit ca04355

Browse files
committed
add cursor position (::>)
1 parent 4dcaf38 commit ca04355

File tree

9 files changed

+55
-56
lines changed

9 files changed

+55
-56
lines changed

coderoad.json

Lines changed: 27 additions & 27 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "coderoad-functional-school",
3-
"version": "0.1.9",
3+
"version": "0.1.10",
44
"description": "Coderoad tutorial",
55
"author": "Shawn McKay <shawn.j.mckay@gmail.com> (http://shmck.com)",
66
"contributers": [

tutorial/1/01/filter.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ console.log(data[0]);
7272
))
7373
@action(insert(
7474
```
75-
function isAda() {
76-
// write condition here
75+
function isAda(::>) {
7776
// return true if student name
7877
// matches "Ada Lovelace"
7978
@@ -90,7 +89,7 @@ function isAda() {
9089
@action(insert(
9190
```
9291
// call filter condition here
93-
var myData = data.filter();
92+
var myData = data.filter(::>);
9493
```
9594
))
9695
@hint('Add a function to the `filter` call: `Array.filter(function() {})`')
@@ -104,7 +103,7 @@ var myData = data.filter();
104103
105104
// return true if student.grade is not a "D" or "F"
106105
function isGoodGrade(student) {
107-
106+
::>
108107
}
109108
```
110109
))
@@ -118,7 +117,7 @@ function isGoodGrade(student) {
118117
@action(insert(
119118
```
120119
// filter out "D"'s and "F"'s here
121-
var myBest = myData.filter();
120+
var myBest = myData.filter(::>);
122121
123122
```
124123
))

tutorial/1/02/sort.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function compareScore(a, b) {
4141
switch (true) {
4242
case b.score > a.score:
4343
// it should return 1 if b's score is more than a's
44-
return
44+
return ::>
4545
case 'set condition here':
4646
// it should return -1 if b's score is less than a's
4747
@@ -65,7 +65,7 @@ function compareScore(a, b) {
6565
@action(insert(
6666
```
6767
// use the compare function to sort myBest
68-
var mySorted = myBest
68+
var mySorted = myBest::>
6969
```
7070
))
7171
@hint('try using `myBest.sort()`')

tutorial/1/03/map.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Let's go back to before we filtered out the bad grades, and instead change the g
6262
@action(set(
6363
```
6464
// change any `student.grade`'s into an 'A'
65-
function changeGrade() {
65+
function changeGrade(::>) {
6666
6767
}
6868
```
@@ -77,7 +77,7 @@ function changeGrade() {
7777
@action(insert(
7878
```
7979
// map over `myData` with the `changeGrade` function
80-
var myChanged = myData.map();
80+
var myChanged = myData.map(::>);
8181
```
8282
))
8383

@@ -89,7 +89,7 @@ Let's go back to `myData` and instead increment each score by 12 points.
8989
@action(insert(
9090
```
9191
92-
function increaseScore() {
92+
function increaseScore(::>) {
9393
9494
}
9595
@@ -143,7 +143,7 @@ var myFixed = mySlightlyChanged;
143143
144144
// set `scoresAndGrades` to an array of scores and grades
145145
// it should return an array of objects like this: {score: 75, grade: 'C'}
146-
var scoresAndGrades = myFixed;
146+
var scoresAndGrades = myFixed::>
147147
```
148148
))
149149
@hint('use `map` to return only the "score" & "grade" fields')

tutorial/1/04/forEach.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function logCourse(course) {
9696
}
9797
9898
// log your grades to the console
99-
myFixed.forEach();
99+
myFixed.forEach(::>);
100100
```
101101
))
102102
@hint('call `forEach` with `logCourse`')
@@ -107,7 +107,7 @@ myFixed.forEach();
107107
```
108108
109109
// add a second param called 'index' to the function
110-
function logCourseWithIndex(course) {
110+
function logCourseWithIndex(course::>) {
111111
console.log(`${index + 1} ${course.grade} ${course.score} ${course.title}`);
112112
}
113113
@@ -124,7 +124,7 @@ myFixed.forEach(logCourseWithIndex);
124124
```
125125
126126
// add a third param called 'array' to the function
127-
function logCourseWithIndexAndArray(course, index) {
127+
function logCourseWithIndexAndArray(course, index::>) {
128128
console.log(`${index + 1}/${array.length} ${course.grade} ${course.score} ${course.title}`);
129129
}
130130

tutorial/1/05/find.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Find is great for performantly matching unique values in data, such as an "id",
3131
@action(set(
3232
```
3333
// filter for the student title matches "Web Security"
34-
var myClass = students.filter();
34+
var myClass = students.filter(::>);
3535
```
3636
))
3737
@hint('create a `filter` function')
@@ -50,7 +50,7 @@ var otherStudents = ["Albert Gonzalez", "Brian Kernaghan", "Danielle Bunten Berr
5050
```
5151
// search for a student with a name
5252
// not matching students in `otherStudents`
53-
function notInList() {
53+
function notInList(::>) {
5454
5555
}
5656
@@ -68,7 +68,7 @@ var unknownStudent = myClass.find();
6868
```
6969
7070
// filter using `notInList`
71-
var unknownStudentList = students.filter();
71+
var unknownStudentList = students.filter(::>);
7272
```
7373
))
7474
@hint('consider reusing a function')
@@ -79,7 +79,7 @@ var unknownStudentList = students.filter();
7979
```
8080
8181
// list only student names
82-
var unknownStudentNames = unknownStudentList.map();
82+
var unknownStudentNames = unknownStudentList.map(::>);
8383
```
8484
))
8585
@hint('use `map` to return only the `student.name`')
@@ -90,7 +90,7 @@ var unknownStudentNames = unknownStudentList.map();
9090
```
9191
9292
// use `.join('')` to join the array of strings
93-
var decodedName = unknownStudentNames;
93+
var decodedName = unknownStudentNames::>;
9494
console.log(decodedName);
9595
```
9696
))

tutorial/1/06/concat.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Array.prototype.flatten = function() {
114114
var numberedList = [[1, 2], [3, 4]];
115115
116116
// use `flatten` on `numberedList`
117-
var flattenedArray = numberedList;
117+
var flattenedArray = numberedList::>;
118118
```
119119
))
120120
@hint('call `.flatten()` on `numberedList`')
@@ -138,7 +138,7 @@ var doubleArray = courses.map(function(course) {
138138
return course.students.map(function(student) {
139139
return {
140140
// fill in the fields
141-
title: '',
141+
title: ::>'',
142142
instructor: '',
143143
name: '',
144144
score: '',
@@ -157,7 +157,7 @@ var doubleArray = courses.map(function(course) {
157157
@action(insert(
158158
```
159159
// `flatten` doubleArray
160-
var students = doubleArray;
160+
var students = doubleArray::>;
161161
```
162162
))
163163
@hint('call `.flatten()` on `doubleArray`')
@@ -170,7 +170,7 @@ var students = doubleArray;
170170
var suspects = ["Hack Kerr"];
171171
// filter to data matching `suspects`
172172
173-
var suspectData = students;
173+
var suspectData = students::>;
174174
```
175175
))
176176

tutorial/1/07/reduce.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function add(a, b) {
6060
}
6161
6262
// total the numbers using a reduce function
63-
var total = practice.reduce();
63+
var total = practice.reduce(::>);
6464
```
6565
))
6666
@hint('with only numbers, the initialValue defaults to 0')
@@ -75,7 +75,7 @@ var total = practice.reduce();
7575
7676
var averages = courses.map(function(course) {
7777
var sum = course.students.reduce(function(total, student) {
78-
78+
::>
7979
8080
});
8181
return Math.round(sum / course.students.length, 0);
@@ -100,7 +100,7 @@ var suspectScores = suspectData.reduce(function(total, next) {
100100
});
101101
if (index < 0) {
102102
total.push({
103-
103+
::>
104104
105105
});
106106
} else {
@@ -131,7 +131,7 @@ var suspectScores = suspectData.reduce(function(total, next) {
131131
132132
var suspectStats = suspectScores.map(function(suspect) {
133133
// calculate the total difference in scores from the averages
134-
var difference = suspect.scores.reduce();
134+
var difference = suspect.scores.reduce(::>);
135135
136136
return {
137137
name: suspect.name,
@@ -158,7 +158,7 @@ function isCheater(suspect) {
158158
}
159159
160160
// reduce down to a string of likely suspects
161-
var likelySuspects = suspectStats.reduce(function() {}, []);
161+
var likelySuspects = suspectStats.reduce(function(::>) {}, []);
162162
```
163163
))
164164
@hint('use `.join(', ')`')

0 commit comments

Comments
 (0)