Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indicate failure to export functions, rather than return null in top level #1

Open
wants to merge 4 commits into
base: full-time
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 54 additions & 52 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions problems/01-my-for-each.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*******************************************************************************
Write a function `myForEach` that accepts an array and a callback as arguments.
The function should call the callback on each element of the array, passing in the
element, index, and array itself. The function does not need to return any value.
Write a function `myForEach` that accepts an array and a callback as
arguments. The function should call the callback on each element of the
array, passing in the element, index, and array itself. The function
does not need to return any value.

Do not use the built in Array.forEach.

Expand All @@ -22,12 +23,12 @@ console.log(test); // ['LAIKA', 'BELKA']
*******************************************************************************/

function myForEach(array, cb) {
// Your code here
// Your code here
}

/*****************DO NOT MODIFY ANYTHING UNDER THIS LINE**********************/
try {
module.exports = myForEach;
} catch(e) {
return null;
module.exports = myForEach;
} catch (e) {
console.error('failed to export myForEach:', e)
}
8 changes: 4 additions & 4 deletions problems/02-my-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ console.log(result2); // [ 'RUN!', 'FORREST!' ]
*******************************************************************************/

function myMap(array, cb) {
// Your code here
// Your code here
}

/*****************DO NOT MODIFY ANYTHING UNDER THIS LINE**********************/
try {
module.exports = myMap;
} catch(e) {
return null;
module.exports = myMap;
} catch (e) {
console.error('failed to export myMap:', e);
}
4 changes: 2 additions & 2 deletions problems/03-multi-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ console.log(result3); // hi!!!!!
*******************************************************************************/

function multiMap(val, n, cb) {
// Your code here
// Your code here
}

/*****************DO NOT MODIFY ANYTHING UNDER THIS LINE**********************/
try {
module.exports = multiMap;
} catch(e) {
return null;
console.error('failed to export multiMap:', e);
}
8 changes: 4 additions & 4 deletions problems/04-my-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ console.log(result2); // ['choose', 'words', 'only']
*******************************************************************************/

function myFilter(array, cb) {
// Your code here
// Your code here
}

/*****************DO NOT MODIFY ANYTHING UNDER THIS LINE**********************/
try {
module.exports = myFilter;
} catch(e) {
return null;
module.exports = myFilter;
} catch (e) {
console.error('failed to export myFilter:', e);
}
8 changes: 4 additions & 4 deletions problems/05-selective-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ console.log(selectiveMap([-10, 4, 7, 6, -2, -9], isPositive, square));
*******************************************************************************/

function selectiveMap(array, selector, mapper) {
// Your code here
// Your code here
}

/*****************DO NOT MODIFY ANYTHING UNDER THIS LINE**********************/
try {
module.exports = selectiveMap;
} catch(e) {
return null;
module.exports = selectiveMap;
} catch (e) {
console.error('failed to export selectiveMap:', e);
}
6 changes: 3 additions & 3 deletions problems/06-reject.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ console.log(reject(['breadth', 'GRAPH', 'depth', 'height'], hasA)); // [ 'depth'
*******************************************************************************/

function reject(array, cb) {
// Your code here
// Your code here
}

/*****************DO NOT MODIFY ANYTHING UNDER THIS LINE**********************/
try {
module.exports = reject;
} catch(e) {
return null;
} catch (e) {
console.error('failed to export reject:', e);
}
8 changes: 4 additions & 4 deletions problems/07-my-some.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ console.log(result3); // true
*******************************************************************************/

function mySome(array, cb) {
// Your code here
// Your code here
}

/*****************DO NOT MODIFY ANYTHING UNDER THIS LINE**********************/
try {
module.exports = mySome;
} catch(e) {
return null;
module.exports = mySome;
} catch (e) {
console.error('failed to export mySome:', e);
}
4 changes: 2 additions & 2 deletions problems/08-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ console.log(result4); // 0
*******************************************************************************/

function count(array, cb) {
// Your code here
// Your code here
}

/*****************DO NOT MODIFY ANYTHING UNDER THIS LINE**********************/
try {
module.exports = count;
} catch(e) {
return null;
console.error('failed to export count:', e);
}
4 changes: 2 additions & 2 deletions problems/09-chain-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ console.log(chainMap(4, half, square)); // 4
*******************************************************************************/

function chainMap(val, ...callbacks) {
// Your code here
// Your code here
}

/*****************DO NOT MODIFY ANYTHING UNDER THIS LINE**********************/
try {
module.exports = chainMap;
} catch(e) {
return null;
console.error('failed to export chainMap:', e);
}
Loading