HW #3 - Stuck

by kristenconnal

JavaScript

/* homework3.js */
"use strict";

// First we do a self-invoking function that contains everything - there will be nothing
//  exposed to the global scope.
(function() {


  var button = document.getElementById("doit");
  button.onclick = function() {
    /*  This function will run when the user clicks on the
     *  Save button.  We're going to do several things when this function
     *  runs:
     *  1) Get the values from the form. We have done this part for you
     *  2) Create a new data object that contains the information from the form. This could be
     *     a constructor funtion that takes each of the values as its arguments, or a simple
     *     JSON object (an object literal, more or less).
     *  3) Write this data object to the page. You'll do this by calling writeRowToPage() and
     *     passing your data object as a parameter.  We have provided a sample of this
     *     function for you, though you may have to modify/complete it so that it works
     *     with your data structure.
     *  4) Store your data to localStorage.  Remember that localStorage stores only
     *     strings, so you'll need to stringify your object. Remember, too, that when you
     *     write to localStorage, you can't add to or modify what's already there - you can only
     *     replace it completely, so you'll need a strategy to manage your accumulating data. See the
     *     Homework 3 PDF document for more information.
     *
     *     */

    //Step #1 - we get values from the form
    var name = document.getElementById("name").value;
    var artist = document.getElementById("artist").value;
    var song = document.getElementById("song").value;

    // Step #2 - you will create a new data object
    function musicEntry(n, a, s) {
      this.name = n;
      this.artist = a;
      this.song = s;
    }

    var musicLog = new musicEntry(name, artist, song);
    var musicLogArray = [];
    musicLogArray.push(musicLog);

    // Step #3 - call on...