You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Clement Denis 3cdfd1a34c discovery-piscine: update exercises and test 4 years ago
..
README.md discovery-piscine: update exercises and test 4 years ago

README.md

Alter Ego 🎭

You can change your objects in multiple ways:

  • modify values of properties
  • add new properties
  • delete properties

Modifying objects

Let's declare an object

// we create our object with 2 properties
const user = {
  points: 0,
  code: '75lai78wn',
}

Adding a new properperty

user.name = 'Martin' // we add a name to our user

The syntax is very similar to modifying a variable, the only difference is we start from our user and use the . (property accessor operator)

Changing a property value

user.points = 10 // set points to 10 points

The syntax is the same, if the property already exist, its value will be changed !

Removing a property

user.code = undefined // remove the value from a property

The trick here is to set its value to undefined as this will clear the value of our property

Instructions

Modify the provided alterEgo variable:

  • add a self property with the string value 'altered'.
  • add a fullName property that is the joined value of the firstName and the lastName with a space in between.
  • add 10 to it's points property