title: How to Zip files using jszip library
body: <p>Am working on an offline application using HTML5 and jquery for mobile. i want to back up files from the local storage using jszip. below is a code snippet of what i have done...</p>
  
  <pre><code>  if (localStorageKeys.length &gt; 0) {
              for (var i = 0; i &lt; localStorageKeys.length; i++) {
                  var key = localStorageKeys[i];
                  if (key.search(_instrumentId) != -1) {                  
                          var data = localStorage.getItem(localStorageKeys[i])
                          var zip = new JSZip();
                          zip.file(localStorageKeys[i] + ".txt", data);
                          var datafile = document.getElementById('backupData');
                          datafile.download = "DataFiles.zip";
                          datafile.href = window.URL.createObjectURL(zip.generate({ type: "blob" }));                        
                  }
                  else {
  
                  }
  
  
              }
  
          }
  </code></pre>
  
  <p>in the code above am looping through the localstorage content and saving ezch file in a text format. the challenge that am facing is how to create several text files inside <strong>DataFiles.zip</strong> as currently am only able to create one text file inside the zipped folder. Am new to javascript so bare with any ambiguity in my question.
  thanks in advance.</p>