store an object in parent object through javascript

34 Views Asked by At

I have an signup form asking firstname, lastname, email, password and I have to save them as object where object key should be firstname like below structure.

firstname(i.e charan ) : {
firstname : 'charan',
lastname : 'naidu',
email: [email protected],
password : 12344,
}
1

There are 1 best solutions below

3
Chris Barr On BEST ANSWER

Once you have created the Accounts variable, you can then create a new object on it by just giving it a value. Accounts.sai = { ... }

const Accounts = {
    chinnu: {
        slitID: 3452309,
        fistName: 'chinnu',
        lastName: 'karam',
        email: '[email protected]',
        password: 'abscs*1',
    }
}

Accounts.sai = {
    slitID: 3423409,
    fistName: 'sai',
    lastName: 'athul',
    email: '[email protected]',
    password: 'silaka*1',
}

console.log(Accounts);