I was wondering how to do this in the more cleaner and optimal way:
I have an Object with the following structure:
{ \"125\": 2, \"439\": 3,
Try this:
var obj = { "125": 2, "439": 3, "560": 1, "999": 2 } var arr = []; for (prop in obj) { for (var i = 0; i < obj[prop]; i++) arr.push(parseInt(prop)); } console.log(arr)