How can I turn this array:
var users = [
{
'date':'jan',
'visits': 2,
'drops': 1
},
{
'date':'feb',
'visits': 3,
'drops': 2
}
]
into this array:
var newArray = [
{
'name': 'visits',
'data': [
2, 3
]
},
{
'name': 'drops',
'data': [
1, 2
]
}
]
using
newArray = users.map(function(){
return ...
});
Thanks!
mapfor this, asusers.lengthandnewArray.lengthare unrelated. You might wantforEachinstead, and simply add to two objects from there.