nt2 nt2 - 1 year ago 65
Javascript Question

how to split an array into two arrays in javascript?

I have an array

var plans=[a, b, c, d ];
with prices based monthly any yearly.

Consider- a and b are monthly and c and d are yearly.

So, I want to split the array based on the monthly and yearly values and store the values in to separate arrays

var monthly_plans=[]; and var yearly_plans=[]

So, how do I do this?

I have used the js
function before but on a very basic level.

Answer Source

I think it will be a better avenue to use a for.


for (var i=0;i<=plans.length;i++)
  if(plans[i] == 'monthly condition')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download