I need to convert a object
{score: 77, id: 166}
to an array,
[77,166]
I tried,
Object.keys(obj).map((key) => [obj[key]]);
but seems like, it returns as 2 arrays.
[[77][166]]
I need to convert a object
{score: 77, id: 166}
to an array,
[77,166]
I tried,
Object.keys(obj).map((key) => [obj[key]]);
but seems like, it returns as 2 arrays.
[[77][166]]
You just had an extra pair of square brackets in your code
const obj = {score: 77, id: 166};
const result = Object.keys(obj).map((key) => obj[key]);
console.log(result)