Cannot pass learnyounode (Make it Modular) ! Please help!

Cannot pass learnyounode (Make it Modular) ! Please help!
0

#1

I don’t understand why I’m getitinng errors. The results matched with the expected but it won’t give me a pass. I’m not sure what I’m doing wrong.

Thank you so much.

This is the output:

~/workspace/learnyounode $ learnyounode verify modular.js

Your submission results compared to the expected:

             ACTUAL                                 EXPECTED                

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

“CHANGELOG.md” == “CHANGELOG.md”
“LICENCE.md” == “LICENCE.md”
“README.md” == “README.md”
"" == “”

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

/home/ubuntu/.nvm/versions/node/v4.4.5/lib/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 (/home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyounode/node_modules/workshopper-exercise/exercise.js:188:18)
at /home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyounode/node_modules/workshopper-exercise/exercise.js:195:7
at callback (/home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyounode/exercises/make_it_modular/verify.js:26:15)
at modFileError (/home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyounode/exercises/make_it_modular/verify.js:31:5)
at /home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyounode/exercises/make_it_modular/verify.js:119:18
at /home/ubuntu/workspace/learnyounode/mymodule.js:14:16
at Array.filter (native)
at /home/ubuntu/workspace/learnyounode/mymodule.js:12:50
at FSReqWrap.oncomplete (fs.js:82:15)


#2

Its hard to help without seeing your actual code, but the error message is saying that it isn’t recognizing the “processors” variable at position i for some reason.

My guess is that the “i” incrementor is exceeding the length of the “processors” array.Calling an array position that doesn’t actually exist would return an “undefined” value. This is likely the cause of the error message "TypeError: Cannot read property ‘call’ of undefined;
at next ". (The relevant information in an error message is usually on the first line)

See if terminating the loop earlier fixes the problem. If not, I could take a look at your actual code.


#4

Oops. Sorry for not posting code.

This is mymodule.js:

module.exports = mymodule;

// Pass each filename.ext in dir to callback
function mymodule(dir, ext, callback) {
var fs = require(“fs”);

fs.readdir(dir, function(err, content){
   if (err){
       return callback(err, content);
   } 
   
   var array = content.toString().split(',').filter(function(a){
       if (-1 != a.search(RegExp('.' + ext))){
           return callback(null, a);
       }
   });
});

};

and the modular.js

var fs = require("./mymodule.js")

fs(process.argv[2], process.argv[3], function(err, data){
if (err) {
console.log(err);
}

console.log(data);

});

Thank you so much for helping!! I greatly appreciate it.


#6

I tried it out after moving up. If I ran “learnyounode run modular.js”, I got what I expected, but the “learnyounode verify modular.js” still gave me the same error.

EDIT - Nvm. I didn’t click save. Yes, that worked!!! Thank you so much.