function writeToFile(answers) {
  return new Promise((resolve, reject) => {
    fs.writeFile(
      `./${answers.title}_README.md`,
      generateMarkdown(answers),
      (err) => {
        // if there's an error, reject the Promise and send the error to the Promise's `.catch()` method
        if (err) {
          reject(err);
          // return out of the function here to make sure the Promise doesn't accidentally execute the resolve() function as well
          return;
        }

        // if everything went well, resolve the Promise and send the successful data to the `.then()` method
        resolve({
          ok: true,
          message: "File created!",
        });
      }
    );
  });
}
// TODO: Create a function to write README file
Create a function to write README file
Create a function to write README file
function writeToFile(answers) {
  return new Promise((resolve, reject) => {
    fs.writeFile(
      `./${answers.title}_README.md`,
      generateMarkdown(answers),
      (err) => {
        if (err) {
          reject(err);
          return;
        }
        resolve({
          ok: true,
          message: "File created!",
        });
      }
    );
  });
}
function writeToFile ( answers ) { return new Promise ( ( resolve , reject ) => { fs . writeFile ( ` ${ answers . title } ` , generateMarkdown ( answers ) , ( err ) => { if ( err ) { reject ( err ) ; return ; } resolve ( { ok : true , message : "File created!" , } ) ; } ) ; } ) ; }
TODO: Create a function to write README file
TODO : Create a function to write README file
// if there's an error, reject the Promise and send the error to the Promise's `.catch()` method // return out of the function here to make sure the Promise doesn't accidentally execute the resolve() function as well // if everything went well, resolve the Promise and send the successful data to the `.then()` method