I'm doing Asabeneh 30 day JavaScript and an exercises requires us to make a sign up function which passes an object newUser to an existing object Users. I can't seem to properly push my newUser object properties to object users. This is my approach to the problem. I've been recently working with object methods.
const users = [
{
_id: 'ab12ex',
username: 'Alex',
email: 'alex@alex.com',
password: '123123',
createdAt:'08/01/2020 9:00 AM',
isLoggedIn: false
},
{
_id: 'fg12cy',
username: 'Asab',
email: 'asab@asab.com',
password: '123456',
createdAt:'08/01/2020 9:30 AM',
isLoggedIn: true
},
{
_id: 'zwf8md',
username: 'Brook',
email: 'brook@brook.com',
password: '123111',
createdAt:'08/01/2020 9:45 AM',
isLoggedIn: true
},
{
_id: 'eefamr',
username: 'Martha',
email: 'martha@martha.com',
password: '123222',
createdAt:'08/01/2020 9:50 AM',
isLoggedIn: false
},
{
_id: 'ghderc',
username: 'Thomas',
email: 'thomas@thomas.com',
password: '123333',
createdAt:'08/01/2020 10:00 AM',
isLoggedIn: false
}
];
const newUser = {
_id: 'fj3093',
username: 'str8cho',
email: 'str8cho@str8cho.com',
password: 'kladjflakjf',
createdAt:'08/01/2020 9:00 AM',
isLoggedIn: false
}
const signUp = function() {
let newList = Object.assign({}, users, newUser);
return newList
}
console.log(signUp())