You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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>.