JavaScript - Objects

Objects practice

by Codi Bezouka-Smith

JavaScript

/*
const user = {
	email: '[email protected]',
	password: 'secret',
};
*/

const user2 = {
	email: '[email protected]',
	password: 'another secret',
};

/*
Object Literals
*/

const user = {
  email: '[email protected]',
  password: 'supersecret',
};

const personalDetails = {
  email: '[email protected]',
  age: 27,
  gender: 'm',
  location: 'New York',
};

const settings = {
  isActive: true,
  hobbies: ['JavaScript', 'Gaming'],
};

const createProfile = (user, details, settings) => {
  return {
    id: 12345,
    ...user,
    ...details,
    ...settings,
  };
};

const createLogEntry = (message, logLevel) => {
  return {
    timestamp: Date.now(),
    message,
    logLevel,
  };
};