2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								id: 587d7b7d367417b2b2512b1e
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								title: Generate an Array of All Object Keys with Object.keys()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								challengeType: 1
							 
						 
					
						
							
								
									
										
										
										
											2019-08-05 09:17:33 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								forumTopicId: 301160
							 
						 
					
						
							
								
									
										
										
										
											2021-01-13 03:31:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								dashedName: generate-an-array-of-all-object-keys-with-object-keys
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# --description--
  
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								We can also generate an array which contains all the keys stored in an object using the `Object.keys()`  method and passing in an object as the argument. This will return an array with strings representing each property in the object. Again, there will be no specific order to the entries in the array.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# --instructions--
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Finish writing the `getArrayOfUsers`  function so that it returns an array containing all the properties in the object it receives as an argument.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# --hints--
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The `users`  object should only contain the keys `Alan` , `Jeff` , `Sarah` , and `Ryan` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								assert(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  'Alan' in users & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'Jeff' in users & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'Sarah' in users & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'Ryan' in users & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    Object.keys(users).length === 4
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								);
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The `getArrayOfUsers`  function should return an array which contains all the keys in the `users`  object
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								assert(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  (function () {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    users.Sam = {};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    users.Lewis = {};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    let R = getArrayOfUsers(users);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return (
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      R.indexOf('Alan') !== -1 & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      R.indexOf('Jeff') !== -1 & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      R.indexOf('Sarah') !== -1 & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      R.indexOf('Ryan') !== -1 & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      R.indexOf('Sam') !== -1 & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      R.indexOf('Lewis') !== -1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    );
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  })() === true
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# --seed--
  
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## --seed-contents--
  
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								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) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 23:18:30 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  // Only change code below this line
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-02 23:18:30 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  // Only change code above this line
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								console.log(getArrayOfUsers(users));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 19:02:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# --solutions--
  
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```js
							 
						 
					
						
							
								
									
										
										
										
											2018-10-20 21:02:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								let users = {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  Alan: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    age: 27,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    online: false
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  },
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  Jeff: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    age: 32,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    online: true
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  },
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  Sarah: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    age: 48,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    online: false
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  },
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  Ryan: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    age: 19,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    online: true
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-10-15 17:19:27 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function getArrayOfUsers(obj) {
							 
						 
					
						
							
								
									
										
										
										
											2019-08-11 09:42:19 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  return Object.keys(obj);
							 
						 
					
						
							
								
									
										
										
										
											2018-10-15 17:19:27 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2018-10-20 21:02:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								console.log(getArrayOfUsers(users));
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```