0

How can I convert this object

{
    priorities: {
        1: "categoryOne"
        2: "categoryTwo"
    }
}

to this array :

[ {1: "categoryOne"}, {2: "categoryOne"} ]
0

1 Answer 1

2

Take entries of object and then map it:

var obj= { priorities: { 1: "categoryOne", 2: "categoryTwo" }};
var result = Object.entries(obj.priorities).map(([k,v])=>({[k]:v}));

console.log(result);

Sign up to request clarification or add additional context in comments.

1 Comment

your answer very helpful tnx

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.