β
Submission results match expected
β
Additional module file exports a single function
β
Additional module file exports a function that takes 3 arguments
β
Your additional module file [mymodule.js] does not appear to pass back an
error received from fs.readdir(). Use the following idiomatic Node.js
pattern inside your callback to fs.readdir(): if (err) return
callback(err)
'Official' Solution
Here's the official solution in case you want to compare notes:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
_/usr/local/lib/node_modules/learnyounode/exercises/make_it_modular/soluti
on/solution.js_ :
'use strict'
const filterFn = require('./solution_filter.js')
const dir = process.argv[2]
const filterStr = process.argv[3]
filterFn(dir, filterStr, function (err, list) {
if (err) {
return console.error('There was an error:', err)
}
list.forEach(function (file) {
console.log(file)
})
})
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
_/usr/local/lib/node_modules/learnyounode/exercises/make_it_modular/soluti
on/solution_filter.js_ :
'use strict'
const fs = require('fs')
const path = require('path')
module.exports = function (dir, filterStr, callback) {
fs.readdir(dir, function (err, list) {
if (err) {
return callback(err)
}
list = list.filter(function (file) {
return path.extname(file) === '.' + filterStr
})
callback(null, list)
})
}
Below, kindly see My Solution and LMK what is the issue with this one in comparison to 'Official' Solution. They seem very similar. π
My Solution
'make-it-modular.js'
'mymodule.js'
'Official' Solution