Hi,
I have been pair programming to try to completed the NodeJS lessons and his code passes and mine does not:
Code is the same.
bizzel:~/workspace $ learnyounode verify program.js
{ [Error: ENOTDIR: not a directory, scandir ‘/tmp/_learnyounode_3948.txt’]
errno: -20,
code: ‘ENOTDIR’,
syscall: ‘scandir’,
path: ‘/tmp/_learnyounode_3948.txt’ }
Your submission results compared to the expected:
ACTUAL EXPECTED
“” != “23”
✗ Submission results did not match expected!
program.js
var readdir = require("./readdir");
readdir(process.argv[2],process.argv[3], function(err, fileList){
if (err) return console.error(err);
var count = 0;
fileList.forEach(function(file) { count++ });
return (count);
});
readdir.js
var fs = require("fs");
var path = require('path');
module.exports = function(dir, filterstr, callbk) {
fs.readdir(dir, function(err, fileList){
if (err) return callbk(err);
var filteredAry = fileList.filter(filterByExtn);
callbk(null, filteredAry);
});
function filterByExtn(fName) {
if (fName == undefined) return false;
if (fName.indexOf('.') === -1) {
return false;
} else {
return path.extname(fName) === '.' + filterstr;
}
}
};