How to keep a scoring history?

How to keep a scoring history?

I have written a small app using jQuery Mobile and Phonegap in which the user is given some text to correct and when he is finished he clicks on a "Get Score" button and is shown in an alert how many answers were correct and how many were incorrect.

I would like to improve this so that after being shown the latest results the user is shown his score for today and for previous days.

I started by adding a page with a text box and then comparing today's date with the last date used which lis stored via localStorage. I then compare the two date strings and if today is a new day load the old results from  localStorage and write them to a text box. I would then like to append the new results to this list and if the user has another try on the same day replace the appended score with the latest score for today. When the user leaves the entire list is saved to  localStorage ready for the next time he uses the app.

I'm afraid I have got myself tied up in a knot with what surely is a simple task. Here is the relevant part of my script as it stands, some lines are commented out from my attempts to find out what I'm doing wrong. 

Any advice would be welcome, even if it is scrap the lot and do it this way.

  1. storedDate = localStorage.getItem("storeDate");
  2. if(storedDate === todaysDate){
  3. // $('#totalText').last().remove();
  4. totalPlus = totalPlus + plusPoints;
  5. totalMinus = totalMinus + minusPoints;
  6. result = todaysDate + " correct " + totalPlus + " incorrect " + totalMinus + "<br>";
  7. $('#totalText').append(result);
  8. // $('#totalText').append('<div class="added"></div>');
  9. // $('.added').html(result);
  10. }
  11. else {
  12. var resultHistory = localStorage.getItem("resHistory");
  13. $('#totalText').append(resultHistory);
  14. // $('#totalText').append('<div class="history"></div>');
  15. // $('.history').html(resultHistory);
  16. localStorage.setItem("storeDate", todaysDate);
  17. totalPlus = plusPoints;
  18. totalMinus = minusPoints;
  19. result = todaysDate + " correct " + totalPlus + " incorrect " + totalMinus;
  20. // $('#totalText').append('<div class="added"></div>');
  21. // $('.added').html(result);
  22. }
  23. localStorage.setItem("resHistory", $('#totalText').html());