getObjectValues

Easy · Object Manipulation · 2 test cases

Given an object, return an array of its values.

Examples

getObjectValues({a: 1, b: 2, c: 3}) → [1, 2, 3]
getObjectValues({name: 'John', age: 30}) → ['John', 30]

Starter code

function getObjectValues(obj) {

}

Complexity of the optimal solution

Time O(n), space O(n). `Object.values(obj)` iterates through the object's 'n' properties and creates a new array containing their values. Both time and space complexity are linear with respect to the number of properties.

Solve getObjectValues in the browser