Here is the code snippet I am working with:
let users2 = [
{
_id: 'ab12ex',
username: 'Alex',
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1f7e737a675f7e737a67317c4e0">[email protected]</a>',
password: '123123',
createdAt:'08/01/2020 9:00 AM',
isLoggedIn: false
},
// More user objects here...
];
// Function to sign up new users
const signUp = (username, email, password, isLoggedIn) => {
let obj = {
_id: 'ddfcd',
username: username,
email: email,
password: password,
createdAt:`${date.getDate()}/${date.getMonth()}/${date.getFullYear()} ${exactTime}`,
isLoggedIn: isLoggedIn
}
let arr = [`${users2.length}`, obj]
let collection = Object.entries(users2)
collection.push(arr)
users2 = collection
}
// Sign up new users
signUp('ali','<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8aebe6e3cae7eb63075b">[email protected]</a>','123',false)
signUp('kerem','<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="157e706770785565677a617a73b767a78">[email protected]</a>','456',false)
signUp('johndoe','<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cfa5ab8fa5abe1aca4e2">[email protected]</a>','789',true)
When adding a new user, the first one looks fine. However, when adding a second user or more, it seems to convert the array into an object. Here is an example of what occurs.
What could be causing this issue?