Here are the browsers cookies:
console.log(document.cookie);
//=> name_instagram=true; name_googleplus=true;
And here is my code:
console.log(document.cookie.split(';').filter( (c) => c.startsWith(parts[1])).map( (d) => d.replace(/.*_(.*)=true/, "$1")));
//=> ["instagram"]
While the expected result is ["instagram", googleplus]. How can I get that?
Currently as you see, just the last item in the cookie will be stored into the array as result value. What's wrong?
parts[1]? "name_"?name. i.evar parts = ['id', 'name'];startsWithfilter second item in array will be " name_googleplus=true;", note leading space, so it starts with " name_" instead of "name_".