0

I have a form, I want to push the inputs when they filled into an array but making the whole data into an object first, from my structure below, when form is filled, push all the data that is filled into an object then push that object into an array, how can I solve this, been racking my head since, and nothing seems to come. the accounts array is behaving more like a container Object below, how can i pass the inputs into objects then pass them into the accounts array Javascript

const account1 = {
  name: 'Oladayo Miracle',
  deposit: [200, 450, -400, 3000, -650, -130, 70, 1300],
username:dayo
  // movements: getItems(),
  interestRate: 1.2, // %
  pin: 1111,
  Dates: [
    '2019-11-18T21:31:17.178Z',
    '2019-12-23T07:42:02.383Z',
    '2020-01-28T09:15:04.904Z',
    '2020-04-01T10:17:24.185Z',
    '2020-05-08T14:11:59.604Z',
    '2021-06-29T17:01:17.194Z',
    '2021-07-02T10:36:17.929Z',
    '2021-07-01T10:51:36.790Z',
  ],
  currency: 'NGN',
  locale: 'en-NG', // de-DE
  exc: 180,
};
const account2 = {
  name: 'Ogunleye Oluwafemi',
  deposit: [5000, 3400, -150, -790, -3210, -1000, 8500, -30, 900],
username:dayo

  interestRate: 1.5, // %
  pin: 2222,
  Dates: [
    '2019-11-01T13:15:33.035Z',
    '2019-11-30T09:48:16.867Z',
    '2019-12-25T06:04:23.907Z',
    '2020-01-25T14:18:46.235Z',
    '2020-02-05T16:33:06.386Z',
    '2020-04-10T14:43:26.374Z',
    '2020-06-25T18:49:59.371Z',
    '2020-07-26T12:01:20.894Z',
    '2020-07-26T12:01:20.894Z',
  ],
  currency: 'USD',
  locale: 'en-US',
  exc: 190,
};
const account3 = {
  name: 'Uduak Blessing',
  deposit: [5000, 3100, -150, -3210, -1000, 8500, -30],
username:dayo
  interestRate: 1.4, // %
  pin: 3333,
  Dates: [
    '2019-11-18T21:31:17.178Z',
    '2019-12-23T07:42:02.383Z',
    '2020-01-28T09:15:04.904Z',
    '2020-04-01T10:17:24.185Z',
    '2020-05-08T14:11:59.604Z',
    '2021-06-29T17:01:17.194Z',
    '2021-07-02T10:36:17.929Z',
    '2021-07-01T10:51:36.790Z',
  ],
  currency: 'USD',
  locale: 'en-US',
  exc: 10,
};
const account4 = {
  name: 'Oluwaremilekum Tayo Makinde',
  deposit: [5000, 3400, -1500, -790, -3210, -1000, 8500],
username:dayo
  interestRate: 1.6, // %
  pin: 4444,
  Dates: [
    '2019-11-01T13:15:33.035Z',
    '2019-11-30T09:48:16.867Z',
    '2019-12-25T06:04:23.907Z',
    '2020-01-25T14:18:46.235Z',
    '2020-02-05T16:33:06.386Z',
    '2020-04-10T14:43:26.374Z',
    '2020-06-25T18:49:59.371Z',
    '2020-07-26T12:01:20.894Z',
  ],
  currency: 'USD',
  locale: 'en-US',
  exc: 30,
};
const accounts = [account1, account2, account3, account]

HTML

<form
            class="modal-form"
            action=""
            name="login"
            method=""
            id="form-id"
            required
          >
            <div>
              <label for="name">Name:</label>
              <input type="text" id="name" />
            </div>
            <div>
              <label for="pin">Password:</label>
              <input type="number" id="pin" />
            </div>
            <div>
              <label for="user">Username:</label>
              <input type="text" id="user" />
            </div>
            <div>
              <label for="rate">Interest:</label>
              <input type="number" id="rate" />
            </div>
            <div>
              <label for="deposit">Deposit:</label>
              <input type="text" id="rate" />
            </div>
            <div>
              <label for="date">Dates:</label>
              <input type="number" id="rate" />
            </div>
            <div>
              <label for="currency">Currency:</label>
              <input type="text" id="currency" />
            </div>
            <div>
              <label for="exchange">Exc rate:</label>
              <input type="number" id="exchange" />
            </div>
            <div>
              <label for="locale">locale:</label>
              <input type="text" id="locale" />
            </div>
            <button type="submit" class="btn header-button">
              Login &rarr;
            </button>
</form>
  • Please do not just ask again when your question gets closed as a dupe. At least explain why it is NOT a dupe – mplungjan Aug 02 '21 at 13:15

0 Answers0