brooke_theperson Posted October 23, 2017 Share Posted October 23, 2017 (edited) So I am working on a simple client database type program. I have a clients array that stores new clients that all have a first name, last name, phone number, etc... I also want the user to be able to add notes about their clients' family. So, one of the parameters of the client function is an array called familyNotes. Here is the code for this: function client(firstName, lastName, phoneNumber, address, hireDate, frequency, cost, entry, familyNotes) { this.firstName = firstName; this.lastName = lastName; this.phoneNumber = phoneNumber; this.address = address; this.hireDate = hireDate; this.frequency = frequency; this.cost = cost; this.entry = entry; this.familyNotes - familyNotes; } var laura = new client("laura", "simmerman", "1111111111", "laura rd", "01/01/01", "weekly", "100", "garage-1111"); var jana = new client("jana", "simmerman", "2222222222", "jana rd", "01/01/01", "weekly", "100", "garage-2222"); var clients = [laura, jana]; However, I do not know if the familyNotes array is working properly. I have a function that prompts the user to add a note about the family of a client, then adds the note to the array. Here is the code for this function: function addFamilyNotes(i) { var note = prompt("Add a note about the family: "); document.getElementById("familyNotes").innerHTML += "<li>" + note + "</li>"; clients[i].familyNotes.push(note); } I later have a function that is supposed to alert the length of the familyNotes array, however it doesn't alert anything currently. Here is the code: function familyNotesAlert(i) { alert(clients[i].familyNotes.length); } Does anyone know what I am doing wrong? Why is the alert not showing, and is anything actually being added to the familyNotes array? Edited October 23, 2017 by brooke_theperson Code needed to be formatted properly Link to comment Share on other sites More sharing options...
justsomeguy Posted October 23, 2017 Share Posted October 23, 2017 You should check your developer console for error messages, I'm sure you'll see an error message that clients.familyNotes is undefined. Check your assignment statement when you set that value. Link to comment Share on other sites More sharing options...
brooke_theperson Posted October 23, 2017 Author Share Posted October 23, 2017 So I am just working on this project in notepad. Where would I find error messages? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 24, 2017 Share Posted October 24, 2017 Open your browser's developer tools and go to the Console tab. In various browsers you might use F12 or Ctrl-Shift-I to open them, or find it in a menu somewhere. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now