I have an object of Customers; and multiple instances of that objects in customers array:
Here's better picture:
customers[0].first_name = "anna";
customers[0].last_name = "dan";
customers[0].email = "[email protected]";
customers[0].credit_card = "222.324.123"
There are several of these arrays with different info: customers[1], customers[2] etc..
I need to alert everything out so it looks like this:
-----------------------------------------------------
| Customers that have signed up: |
| |
| anna dan [email protected] 222.324.123 |
| contents of customer[1] |
| contents of customer[2] |
| contents of customer[3] |
| contents of customer[4] |
| and so on ... |
|----------------------------------------------------
I don't need to alert the borders that you see, I just drew those to represent how the alert box should be formatted.
Here's what I tried doing which isn't working:
for (i = 0; i < customers.length; i++) {
if (customer[i].hasSignedUp(query) == true) {
R_fname[i] = customers[i].f_name;
R_lname[i] = customers[i].l_name;
R_email[i] = customers[i].email;
R_credit[i] = customers[i].credit_card;
}
}
var fin_str;
for (i = 0; i < R_fname.length; i++) {
fin_str += (R_fname[i] + " " + R_lname[i] + " " + R_email[i] + " " + R_credit[i] + " \n");
}
alert("Customer that have signed up " + "\n" + fin_str);
R_arrays but the i-1 index might not exist, this has strange effects on you second for loop. Also you don't definefin_stras an empty string and therefore the concatentated string will start withundefined