Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 806 Bytes

get-key-value-pairs-as-arrays.md

File metadata and controls

25 lines (17 loc) · 806 Bytes

Get key/value pairs as arrays 7 Kyu

LINK TO THE KATA - ARRAYS FUNDAMENTALS

Description

Complete the keysAndValues function so that it takes in an object and returns the keys and values as separate arrays.

Example:

keysAndValues({ a: 1, b: 2, c: 3 }) // should return [['a', 'b', 'c'], [1, 2, 3]]

Style Points (JS/CoffeeScript only): This kata only tests for data that uses object literal notation (simple objects). For extra style, can you get your method to check for objects that extend their prototype?

Solution

const keysAndValues = data => [Object.keys(data), Object.values(data)]