Learnyounode "Make It Modular" does not pass

102 views
Skip to first unread message

jerome

unread,
Nov 7, 2014, 8:19:08 PM11/7/14
to nod...@googlegroups.com
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);
//      });
//});

John Shaver

unread,
Nov 8, 2014, 12:53:32 AM11/8/14
to nod...@googlegroups.com
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
> --
> 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 nodejs+un...@googlegroups.com.
> To post to this group, send email to nod...@googlegroups.com.
> 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.

greelgorke

unread,
Nov 10, 2014, 4:51:27 AM11/10/14
to nod...@googlegroups.com
please put your question regarding nodeschool workshoppers here https://github.com/nodeschool/discussions
Reply all
Reply to author
Forward
0 new messages