js/script.js
// write the books array data to file

write the books array data to file
write the books array data to file
function commitToFile ( ) {
   var arrayLength = books.length;
   var bookData;
   var writeData;
   writeData = 'var = books [';
   for ( var i=0 ; i < arrayLength ; i++ ) {
      bookData = newlineText + '   { ';
      for ( var propertyName in books[i] ) {
	 if ( propertyName !== bookNumberProperty ) {
	    bookData += propertyName + ': ' + books[i][propertyName] + ', ';
	 }
      }
      writeData += bookData.replace ( /, $/, ' },' );
   }
   writeData += newlineText + '];';
   outputDiv.innerHTML = '<br />Source: ' + bookDataFile + '<br />' + nonBreakingSpaceText + '<br />was intended to be the recipient of this data:<br />' + nonBreakingSpaceText + '<pre>' + writeData + '</pre>';
   console.log ( writeData );
}
function commitToFile ( ) { var arrayLength = books . length ; var bookData ; var writeData ; writeData = 'var = books [' ; for ( var i = 0 ; i < arrayLength ; i ++ ) { bookData = newlineText + '   { ' ; for ( var propertyName in books [ i ] ) { if ( propertyName !== bookNumberProperty ) { bookData += propertyName + ': ' + books [ i ] [ propertyName ] + ', ' ; } } writeData += bookData . replace ( / , $ / , ' },' ) ; } writeData += newlineText + '];' ; outputDiv . innerHTML = '<br />Source: ' + bookDataFile + '<br />' + nonBreakingSpaceText + '<br />was intended to be the recipient of this data:<br />' + nonBreakingSpaceText + '<pre>' + writeData + '</pre>' ; console . log ( writeData ) ; }
write the books array data to file
write the books array data to file
//   var fileHandle = 'insert appropriate API function here'
 // in lieu of some API function such as: writeToFile ( writeData );
