lundi 6 juillet 2015

Picking a few random properties from an Object

If I have a few objects as below:

var points = {'p1':{x:1,y:1,z:2}, 'p2':{x:2,y:1,z:4},.....,'p10':{x:3,y:2:z:2}};
var lines = {'l1':{....},'l2':{....},......,'l10'{....}};
var jsonObject = {'info': 'information', 'points': points, 'lines': lines};

How do I pick (for example, 3 random points and 3 random lines) from respective objects and update in jsonObject such that the new jsonObject now contains {'info': 'information', 'points': pointObj, 'lines': lineObj}; where pointObj contains 3 random points from the orighinal points object and lineObj contains 3 random lines from the original lines object?




Aucun commentaire:

Enregistrer un commentaire