Okay, this is quite related to my previous quesion, but still (so you don't have to travel to that page..)
I have a string in the format
ItemName1:Rate1:Tax1_ItemName2:Rate2:Tax2:_ItemName3:Rate3:Tax3_ItemName4:Rate4:Tax4
the user will pass 4 args, first will tell which element to take, when this list is split by _, and other 3 will tell the new values of items.
For example, if user passes 2, Denim Jeans, 399.00, 14.34. The original string would become
ItemName1:Rate1:Tax1_ItemName2:Rate2:Tax2:_Denim Jeans:399.00:14.34_ItemName4:Rate4:Tax4
First split at _, get the element at index 2 (the value user supplied), and then split that element at : and then replace those items with the value supplied.
I got around a lot, here is the jsfiddle for that. But I am just stuck at the last part that will do the appropriate concatenation.
Can help please help me make this last function?
Edit : updated the fiddle!
$.map()call in your function?listis split by_, map returns the elements of that element when split by:, which is then concatenated to make the string that will be replace._itemsToReplace = ary[index].split(deli2);do the same thing as that first$.map()? (If the callback you pass to$.map()just returns the first parameter unchanged all you're doing is making a shallow copy of the array.)