javascript match two arrays then display max value -


i trying match 2 values in 2 arrays

var months ['jan', 'feb', 'march']; var nodays ['31', '28', '31']; 

then want fin months maximum number , return them such

"both jan , march have total of 31 days"

any suggestions please

well, problem solved simple algorithm:

var months = ['jan', 'feb', 'march']; var nodays = [31, 28, 31];  var maxdays = 0; var longestmonths = []; (var = 0; i<math.min(months.length, nodays.length);i++){    if(nodays[i]>maxdays){        maxdays = nodays[i];        longestmonths = [months[i]];    }else if(nodays[i]==maxdays)        longestmonths.push(months[i]); } 

after executing code, maxdays 31and longestmonths ['jan', 'march']


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -