INNER CODE UNIT · JavaScript

cleanFile

Bharat2044/100xDevs-Cohort3-WebDev-and-Devops · Week 02 - Offline Videos/Assignment Solution/Assignment2 Solution/index.js:15

function cleanFile(filePath, cb) {
  
  return new Promise(function (resolve) {
    // reading the file 
    fs.readFile(filePath, "utf-8", function (err, data) {
      // trimming the data from left and right 
      data = data.trim();

      // writing the data back to the file 
      fs.writeFile(filePath, data, function () {
        resolve();
      });
    });
  });
}

// async function to solve the problem statement
async function solve() {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…