title: retrieving last key in javascript localstorage
body: <p>I am doing a uni assignment so please excuse the coplete lack of knowledge here. I have been tasked with creating a web based app for a "client" that requires me to open an invoice after they have completed all the details, so far I have the form working fine, i can save to localstorage without an issue and can even retrieve the information in the format that I want.</p>
  
  <p>The issue is that if i have multiple "orders' than i can only retrieve the first string saved to localstorage and i cannot figure out how to make it display the newest/last one.</p>
  
  <p>The key is an almost randomly generated number derived from the date as we had to assume a large quantity of orders. I have attached the code below so if anyone can help i would appreciate it. Also I cannot use Jquery or JSON or anything like that. We have been told we are not able to use these. Also i cannot use a server (php etc).</p>
  
  <p>Thanks
  Steve</p>
  
  <pre><code>&lt;script&gt;
  var i = 0;
  
  var itemKey = localStorage.key(i);
  var values = localStorage.getItem(itemKey);
  values = values.split(";");
  var name = values[0];
  var company = values[1];
  var contactnumber = values[2];
  var email = values[3];
  var address1 = values[4];
  var address2 = values[5];
  var suburb = values[6]
  var postcode = values[7];
  var comments = values[8];
  var bags = values[9];
  var distance = values[10];
  var hdelivery_fee = values[11];
  var hprice = values[12];
  var htotal_notax = values[13];
  var hgst = values[14];
  var htotal_tax = values[15];
  var hordernumber  = values[16];
  
  
  document.write('Name: ' + name + '&lt;br /&gt;');
  document.write('Company: ' + company + '&lt;br /&gt;');
  document.write('Contact: ' + contactnumber + '&lt;br /&gt;');
  document.write('Email; ' + email + '&lt;br /&gt;');
  document.write('Address; ' + address1 + '&lt;br /&gt;');
  document.write('Address; ' + address2 + '&lt;br /&gt;');
  document.write('Suburb; ' + suburb + '&lt;br /&gt;');
  document.write('Postcode; ' + postcode + '&lt;br /&gt;');
  document.write('Comments; ' + comments + '&lt;br /&gt;');
  document.write('Number of Bags; ' + bags + '&lt;br /&gt;');
  document.write('Distance; ' + distance + '&lt;br /&gt;');
  document.write('Delivery Fee; $' + hdelivery_fee + '&lt;br /&gt;');
  document.write('Price of Bags; $' + hprice + '&lt;br /&gt;');
  document.write('Total Ex-GST; $' + htotal_notax + '&lt;br /&gt;');
  document.write('GST; $' + hgst + '&lt;br /&gt;');
  document.write('Total Inc GST; $' + htotal_tax + '&lt;br /&gt;');
  document.write('hordernumber; ' + hordernumber + '&lt;br /&gt;');
  
  
  &lt;/script&gt;
  </code></pre>