Skip to content Skip to sidebar Skip to footer

Jquery Malipulate A Subarray, And Return A New Array Using Each/map

I have this string in the form of ItemName1:Rate1:Tax1_ItemName2:Rate2:Tax2:_ItemName3:Rate3:Tax3_ItemName4:Rate4:Tax4 (and so on, upto item 25). What I have to do is, user will pa

Solution 1:

Do you mean something like this?

var items = str.split('_').map(function(v){ return v.split(':') });

That will generate an array:

[
  ["ItemName1","Rate1","Tax1"],
  ["ItemName2","Rate2","Tax2"],
  ["ItemName3","Rate3","Tax3"],
  ["ItemName4","Rate4","Tax4"]
]

Demo: http://jsfiddle.net/elclanrs/7uVDM/


Post a Comment for "Jquery Malipulate A Subarray, And Return A New Array Using Each/map"