Still having trouble with NEXT-PREVIOUS buttons for Dynamic Items. Please help.

getItems returns an array and you cannot store this as local.setItem expects a string or number.

Convert the array to a string.

Substitue dynamicPageURLs for JSON.stringify(dynamicPageURLs)

When retrieving the variable, if you want to convert back to an array, you will need to use JSON.parse(dynamicPageURLs)