title: Convert JavaScript variable value to csv file
body: <p>I have a comma separated variable in my .js file, for example:</p>
  
  <pre><code>var out='';
  out+="1,val1,val2,val3,val4\n";
  out+="2,val1,val2,val3,val4\n";
  out+="3,val1,val2,val3,val4\n";
  </code></pre>
  
  <p>I am displaying this value in a browser using <code>document.write(out);</code>.<br>
  I would like the <code>out</code> variable to be downloadable as a <code>.csv</code> file.</p>
  
  <p>From data stored in a variable, is there any way to create a csv file and its associated download link in JavaScript?</p>
  
  <p><strong><h2><a href="http://jsfiddle.net/ravatsinh/57pME/" rel="noreferrer">jsFiddle</a></h2></strong></p>