Methods:ES6


#1

How do you add to an object like this?

https://www.codecademy.com/courses/learn-javascript-objects/lessons/objects/exercises/methods-es6?action=resume_content_item&course_redirect=introduction-to-javascript


#2

Add it to what? Do you want to have more than one object like that?


Do you mean add more attributes?

Say we have this,

const person = {
  name: "Wee Gillis",
  age: 19
};

and wish to add the two attributes, weekAlarm and weekendAlarm,

person['weekAlarm'] = 'Alarm set to 7AM';
person['weekendAlarm'] = 'No alarms needed';

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.