Basic 3 Flashcards

1
Q

Formula to create an object

A
const person = {
   firstName: 'Steve',
lastName: 'Nuts'
age: 34
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

how can you select values from objects? 2 methods and which one it’s the most common.

A
val = person. firstName;
val = person ['lastName'];
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

how can you do a function in an object?

A

getBirthYear: funcition() {
return 2021 - this.age;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can you get the state alone in a console?

const person = {
  firstName: 'Steve',
  lastName: 'Smith',
  age: 45,
  email: 'joh@dk.com',
  hobbies: ['music', 'sports'],
  address: {
    city: 'Miami',
    state: 'FL'
  },
A

val = person.address.state;

NOTE: REMEMBER TO ASIGN A VALUE ON A OBJECT YOU HAVE TO USE : INSTEAD OF =

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how can you call the result of the function?

A

val = person.getBirthYear();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly