Jump to content

How to add strings to an array that is a parameter of a function?

Recommended Posts

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>";

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) {

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 by brooke_theperson
Code needed to be formatted properly
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...