What you have there looks correct to me, as far as the module. Did you write the script that accepts the command line parameters, requires the module and then passes the parameters into the module?
>From the lesson description: ____ This problem is the same as the previous but introduces the concept of modules. You will need to create two files to solve this. Create a program that prints a list of files in a given directory, filtered by the extension of the files. The first argument is the directory name and the second argument is the extension filter. Print the list of files (one file per line) to the console. You must use asynchronous I/O. ____ If you did, please copy the output of learnyounode verify <name of script that includes the module>. -John On Fri, Nov 7, 2014 at 6:19 PM, jerome <[email protected]> wrote: > 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. -- 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/CAMbK04wdSqpGKUGejjw08fyUynRpOWAt5i26QRo2b%3DmU%2BzWCKw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
