UNPKG

ds-algo-study

Version:

Just experimenting with publishing a package

26 lines (17 loc) 826 B
/*********************************************************************** Write a function `breakDownObj(obj)` that takes in an object as a parameter and returns an array containing: all the keys from the object **and** all the values of the object. **Hint**: Use spread syntax to spread out elements into an array! Examples: let object1 = {name: 'Rupert', age: 5, speak: 'Meow'}; breakDownObj(object1); // => [ 'name', 'age', 'speak', 'Rupert', 5, 'Meow' ] let object2 = {location: 'NY', borough: 'Brooklyn'}; breakDownObj(object2); // => [ 'location', 'borough', 'NY', 'Brooklyn' ] ***********************************************************************/ function breakDownObj(obj) { let keys = Object.keys(obj); let values = Object.values(obj); return [...keys, ...values]; } module.exports = breakDownObj;