. Advertisement .
..3..
. Advertisement .
..4..
How to add new key value pair to dictionary in javascript? Can you give me some suggestions?
Here is a suggestion for youfor (var i = 0; i < input.length; i++) {
var datum = input[i];
if (!d[datum.key]) {
d[datum.key] = [];
}
d[datum.key].push(datum.val);
}
This is the solution that I found somewhere, this helped me and I hope that helps you