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 comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...