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

MAKE IT MODULAR another verify error #537

Open
locdoan12121997 opened this issue May 26, 2017 · 4 comments
Open

MAKE IT MODULAR another verify error #537

locdoan12121997 opened this issue May 26, 2017 · 4 comments

Comments

@locdoan12121997
Copy link

I'm getting an error when verifying the "Make It Modular" exercise.

Here's my make-it-modular.js:

var fs = require('fs');
var path = require('path');

module.exports = function (dir, ext,callback){
  fs.readdir(dir,function(err,list){
    if (err)
      return callback(err);
    for (var i = 0; i< list.length; i++){
      if (path.extname(list[i]) === ('.'+ext))
        callback(list[i]);
    }
  })
}

My module named filtered-ls1.js:

var mymodule = require('./make-it-modular.js');
mymodule(process.argv[2], process.argv[3],console.log);

And here's the output when I run learnyounode verify make_it_modular.js:

Your submission results compared to the expected:

                 ACTUAL                                 EXPECTED
────────────────────────────────────────────────────────────────────────────────

   "CHANGELOG.md"                      ==    "CHANGELOG.md"
   "LICENCE.md"                        ==    "LICENCE.md"
   "README.md"                         ==    "README.md"
   ""                                  ==    ""

────────────────────────────────────────────────────────────────────────────────

 ✓

 Submission results match expected

 ✓

 Additional module file exports a single function

 ✓

 Additional module file exports a function that takes 3 arguments

 ✓

 Additional module file handles errors properly

 ✓

 Additional module file handles callback argument

C:\Users\win\AppData\Roaming\npm\node_modules\learnyounode\node_modules\workshopper-exercise\exercise.js:188
    processors[i].call(self, mode, function (err, pass) {
                 ^

TypeError: Cannot read property 'call' of undefined
    at next (C:\Users\win\AppData\Roaming\npm\node_modules\learnyounode\node_modules\workshopper-exercise\exercise.js:188:18)
    at C:\Users\win\AppData\Roaming\npm\node_modules\learnyounode\node_modules\workshopper-exercise\exercise.js:195:7
    at callback (C:\Users\win\AppData\Roaming\npm\node_modules\learnyounode\exercises\make_it_modular\verify.js:26:15)
    at modFileError (C:\Users\win\AppData\Roaming\npm\node_modules\learnyounode\exercises\make_it_modular\verify.js:31:5)
    at C:\Users\win\AppData\Roaming\npm\node_modules\learnyounode\exercises\make_it_modular\verify.js:119:18
    at C:\Users\win\Desktop\Node js\Nodeschool\learnyounode\make-it-modular.js:9:9
    at FSReqWrap.oncomplete (fs.js:123:15)
@AnshulMalik
Copy link
Contributor

Hey, which node version are you using ? @locdoan12121997

@UjinKosy
Copy link

UjinKosy commented Jun 5, 2017

please take a look at #500
the main issue for that step is callback execution inside loop. Please take callback out from loop and task will be done

@vveliu
Copy link

vveliu commented Jun 22, 2017

@locdoan12121997 your module is defined as

module.exports = function (dir, ext, callback){/*code here*/}

so function() expects three input parameters, dir = directory to parse, ext= file extension to filter and callback.

callback must be a function that prints out error or result list.

Intead of printing out the file name inside module you must print this info in your callback function, defined as parameter or somewhere else in caller.

var foo = function(parm1,param2,pram3...){/*code here*/}

moduleFunction (dir, ext,foo){/*code here*/}

or 

moduleFunction(dir, ext,function(parm1,param2,pram3...){/*code here*/});

@AnshulMalik
Copy link
Contributor

@locdoan12121997 Still stuck?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants