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.
getArrayOfUsers
function so that it returns an array containing all the properties in the object it receives as an argument.
users
object only contains the keys Alan
, Jeff
, Sarah
, and Ryan
'
testString: 'assert("Alan" in users && "Jeff" in users && "Sarah" in users && "Ryan" in users && Object.keys(users).length === 4, "The users
object only contains the keys Alan
, Jeff
, Sarah
, and Ryan
");'
- text: The getArrayOfUsers
function returns an array which contains all the keys in the users
object
testString: '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, "The getArrayOfUsers
function returns an array which contains all the keys in the users
object");'
```