javascript - Check if multiple arrays of the same variable name contain any items -


the example code below uses mix of razor , javascript. renderchart function takes in dates. dates var returns array of dates. i'm wondering how can check date arrays combined see if of them contain items or in case date strings.

foreach (measurementtypegroup group in model.measurementtypegroups){     var dates =  @(html.raw(dates)); // dates returns []          renderchart( dates);          console.log(dates); //console display " [] [] [] or [] [3/2/12] [] } 

initially using if condition check length

if(dates.length === undefined || dates.length === 0) {     //do  } 

this partially works, on every iteration in foreach loop rather on total of date arrays. i'm guessing need return variable , push contents of 1 other i'm having issue figure out how this. help!

you can use concat combine arrays single one. http://www.w3schools.com/jsref/jsref_concat_array.asp

var alldates = []  foreach (measurementtypegroup group in model.measurementtypegroups){     var dates =  @(html.raw(dates)); // dates returns []     alldates.concat(dates); }  renderchart(alldates); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -