-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path19_generatArrayOfObjectKeys.js
More file actions
48 lines (42 loc) · 914 Bytes
/
19_generatArrayOfObjectKeys.js
File metadata and controls
48 lines (42 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* Generate an Array of All Object Keys with
Object.keys() */
const oldUsers = {
Alan: {
online: false
},
Jeff: {
online: true
},
Sarah: {
online: false
}
};
// Object.keys() method generates an array of object keys.
console.log(Object.keys(oldUsers)); // ['Alan', 'Jeff', 'Sarah']
/* Finish writing the getArrayOfUsers function so that it
returns an array containing all the properties in the object it
receives as an argument. */
let users = {
Alan: {
age: 27,
online: false
},
Jeff: {
age: 32,
online: true
},
Sarah: {
age: 48,
online: false
},
Ryan: {
age: 19,
online: true
}
};
function getArrayOfUsers(obj) {
// Only change code below this line
return Object.keys(obj);
// Only change code above this line
}
console.log(getArrayOfUsers(users));