Skip to content
Advertisement

Transform text coma in an array

I am working with the PayPal API and I am trying to add multiple items to my itemList. My problem is that to make the itemList work, the array needs multiples variables:

JavaScript

I am using a loop before, to set-up the items, which I am trying to gather into one variable:

JavaScript

It doesn’t work and I think that the problem is the coma, which I believe is read as plain text, and not as a “technical” coma (I do not know the term).

Please find here the full code for more clarity:

JavaScript

Thank you very much in advance for your help.

Marc

Advertisement

Answer

You are creating a string with a list of the items and not an array of items. I’ve rewritten the code to make this process simpler – no need for variable variables and just add each item in the loop to an overall list of items (using $allTheItems[])…

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement