← Back to challenges

Convert Key, Values in an Object to Array

JavaScriptHardobjectsarrays

Instructions

Write a function that converts an object into an array of keys and values.

Examples

objectToArray({
  D: 1,
  B: 2,
  C: 3
}) ➞ [["D", 1], ["B", 2], ["C", 3]]

objectToArray({
  likes: 2,
  dislikes: 3,
  followers: 10
}) ➞ [["likes", 2], ["dislikes", 3], ["followers", 10]]

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Integer in Range?