Has anybody got experience with the learnyounode "Make It Modular"
challenge? Because I am writing the following code, but it is not passing.
But when I run it with a test usage, everything seems ok. If anybody spots
anything wrong, please let me know.
Here are the two files I have created.
= = = = =
// filtered.js
var fs = require('fs');
var path = require('path');
module.exports = function(dir, ext, callback) {
fs.readdir(dir, function(err, files) {
var pass = [];
if (err) {
return callback(err);
}
files.forEach(function(file) {
if (path.extname(file) === '.' + ext) {
pass.push(file);
}
});
return callback(null, pass);
});
};
= = = = =
// use-filtered-ls.js
var filter = require('./filtered-ls.js');
// Un-comment below to demonstrate usage, which seems to be fine and
*should* pass(?)
//filter('./', 'js', function(err, data) {
// if (err) {
// console.log(err);
// }
//
// data.forEach(function(item) {
// console.log(item);
// });
//});
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/05e040e3-1c87-43c2-8367-a83e514f2117%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.