'Parsing Javascript cookie values and separating values

I'm still learning Javascript and I'm trying to parse a value from a cookie in a specific key:

I'm using this current line:

const cookieObj = new URLSearchParams(document.cookie.replaceAll("; ","&","|")) cookieObj.get("LG_AFF_TRK")

LG_AFF_TRK is the key that I'm pulling the value from. Doing so creates the output value of the following:

1|2|3|4|5|6

Each number represented would be a value that will have a random number of characters -and- could possibly be empty but each section always be separated by the "|" symbol.

How can I pull a specific value? As an example question, what do I need to do pull value 3?

I'm trying to understand this logically and my guess is I have to create an array first?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source