nodeschool learnyounode node.js module FILTER LS exercise

后端 未结 8 1495
面向向阳花
面向向阳花 2021-02-10 05:38

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

8条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-10 06:15

    Here is what I came up with:

    var fs = require('fs');
    var filePath = process.argv[2];
    var fileType = '.' + process.argv[3];
    
    fs.readdir(filePath, function(err, list) {
    for(var i=0; i

提交回复
热议问题