title: How to write a string containing commas to CSV?
body: <p>I am trying to write data into a csv file. The data will always be a string, but it sometimes contains a comma. How do I include the comma when writing to the csv file without it separating them into different columns? I am using the fs module to create the csv file. I would like an explanation if you're using regex as I am not too familiar with it.</p>
  
  <pre><code>const fs = require('fs');
  
  let testArr = ['test1','test,2','test3'];
  
  async function main(){
      try{
          fs.writeFile(('./testCsv.csv'), testArr.join("\n"), 'utf8', function (err){
              if(err) throw err;
              console.log('Saved!');
          });
      }
  }
  </code></pre>
  
  <p>I want the output to look like ( | is used to separate as columns) <code>test1|test,2|test3</code> 
  but it instead looks like 
  <code>test1|test|2|test3</code></p>
  
  <p>One thing I have tried is</p>
  
  <pre><code>const fs = require('fs');
  
  let testArr = ['test","5','test","6','test","7'];
  
  async function main(){
      try{
          fs.writeFile(('./testCsv.csv'), testArr.join("\n"), 'utf8', function (err){
              if(err) throw err;
              console.log('Saved!');
          });
      }
  }
  </code></pre>
  
  <p>but the output looks like</p>
  
  <pre><code>test"|5,test|6,test|7
  </code></pre>
  
  <p>with the 7 looking weird in the file (it was not centered and up-left from it)</p>