Below is the exercise 5 of nodeschool learnyounode module
Create a program that prints a list of files in a given directory, filtered by he extension of the files. You w
thats how i solved it
var fs = require('fs');
const path = require("path")
var dir = process.argv[2],
ext = "."+process.argv[3];
function borer(callback){
fs.readdir(dir,function(err,list){
if(err){
console.log(err)
}else{
var row = list.filter((a)=>{
var regexp = new RegExp(ext+"$","ig")
if( a.search(regexp) > -1 ){
callback(a)
}
})
}
})
}
function print(f){
console.log(f)
}
borer(print)