Skip to content

Commit a121a83

Browse files
committed
fixed some instructions
1 parent f0ce2db commit a121a83

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/arrays.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,44 @@
1-
// Complete the following functions.
2-
// These functions only need to work with arrays.
3-
// Do NOT use the built in array methods to solve these. forEach, map, reduce, filter, includes, etc.
4-
// You CAN use concat, push, pop, etc. but do not use the exact method that you are replicating
5-
// You can use the functions that you have already written to help solve the other problems
1+
/*
2+
Complete the following functions.
3+
These functions only need to work with arrays.
4+
A few of these functions mimic the behavior of the `Built` in JavaScript Array Methods.
5+
The idea here is to recreate the functions from scratch BUT if you'd like,
6+
feel free to Re-use any of your functions you build within your other functions.
7+
You CAN use concat, push, pop, etc. but do not use the exact method that you are replicating
8+
You can use the functions that you have already written to help solve the other problems
9+
*/
610

711
const each = (elements, cb) => {
12+
// Do NOT use forEach to complete this function.
813
// Iterates over a list of elements, yielding each in turn to the `cb` function.
914
// This only needs to work with arrays.
1015
// You should also pass the index into `cb` as the second argument
1116
// based off http://underscorejs.org/#each
1217
};
1318

1419
const map = (elements, cb) => {
20+
// Do NOT use .map, to complete this function.
1521
// Produces a new array of values by mapping each value in list through a transformation function (iteratee).
1622
// Return the new array.
1723
};
1824

1925
const reduce = (elements, cb, startingValue) => {
26+
// Do NOT use .reduce, to complete this function.
2027
// Combine all elements into a single value going from left to right.
2128
// Elements will be passed one by one into `cb` along with the `startingValue`.
2229
// `startingValue` should be the first argument passed to `cb` and the array element should be the second argument.
2330
// `startingValue` is the starting value. If `startingValue` is undefined then make `elements[0]` the initial value.
2431
};
2532

2633
const find = (elements, cb) => {
34+
// Do NOT use .includes, to complete this function.
2735
// Look through each value in `elements` and pass each element to `cb`.
2836
// If `cb` returns `true` then return that element.
2937
// Return `undefined` if no elements pass the truth test.
3038
};
3139

3240
const filter = (elements, cb) => {
41+
// Do NOT use .filter, to complete this function.
3342
// Similar to `find` but you will return an array of all elements that passed the truth test
3443
// Return an empty array if no elements pass the truth test
3544
};
@@ -49,5 +58,5 @@ module.exports = {
4958
reduce,
5059
find,
5160
filter,
52-
flatten,
61+
flatten
5362
};

0 commit comments

Comments
 (0)