Insert datas from a JavaScript array to another one -


i have defined 2 javascript variables arrays array like:

var mymondaysimpressionsdata = new array(['2013-01-21', 2015], ['2013-01-28', 2967], ['2013-02-04', 2419], ['2013-02-11', 1311], ['2013-02-18', 1398], ['2013-02-25', 86161], ['2013-03-04', 216865], ['2013-03-11', 105252], ['2013-03-18', 141978], ['2013-03-25', 4647], ['2013-04-01', 46339], ['2013-04-08', 19920]); 

and:

var mymondaysimpressionspaiddata = new array([0], [0], [0], [0], [0], [69428], [186482], [74850], [107281], [0], [32781], [0]); 

it's kinda mandatory use form because further scopes. issue want take values found in second array , add them example:

var example = new array(['2013-01-21', 2015, 0], ['2013-01-28', 2967, 0], ['2013-02-04', 2419, 0], ['2013-02-11', 1311, 0], ['2013-02-18', 1398, 0], ['2013-02-25', 86161, 69428], ['2013-03-04', 216865, 186482], ['2013-03-11', 105252, 74850], ['2013-03-18', 141978, 107281], ['2013-03-25', 4647, 0], ['2013-04-01', 46339, 32781], ['2013-04-08', 19920, 0]); 

in first array. said, have reach form shown above in example variable. how possible in javascript? method should used in case of scenarios?

use simple loop:

for (var = 0; < mymondaysimpressionsdata.length; i++) {     if (i < mymondaysimpressionspaiddata.length) {         mymondaysimpressionsdata[i].push(mymondaysimpressionspaiddata[0]);     } } 

if want new array, not change first one, copy before. in javascript, done using

var copy = array.slice(); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -