Javascript runs in console but not in Glide column

I have the following javascript that I would like to run in a Glide table column but it does not return anything. When I run it in the browser console I do get the result that I want. Can anyone tell me what I am missing?

This is the code I am running in the console:

let p1 = "M9uEXlz-Rn6Cr2ZHLxNSIA, M9uEXlz-Rn6Cr2ZHLxNSIA, M9uEXlz-Rn6Cr2ZHLxNSIA, M9uEXlz-Rn6Cr2ZHLxNSIA, M9uEXlz-Rn6Cr2ZHLxNSIA, a-qNlSOI8RFS7hR7nUAZ4ww, a-qNlSOI8RFS7hR7nUAZ4ww, vv4CPGykQkK4BN8SsnLd9A, sUe8Ra2eSjyCG7jKZuTo1w, a-qNlSOI8RFS7hR7nUAZ4ww, a-qNlSOI8RFS7hR7nUAZ4ww, vv4CPGykQkK4BN8SsnLd9A, sUe8Ra2eSjyCG7jKZuTo1w";
let arr = p1.split(', ');
let counts = {};
arr.forEach(x => {
   counts[x] = (counts[x] || 0) + 1;
}); 
console.log(counts);

This is the output in the browser console:

{M9uEXlz-Rn6Cr2ZHLxNSIA: 5, a-qNlSOI8RFS7hR7nUAZ4ww: 4, vv4CPGykQkK4BN8SsnLd9A: 2, sUe8Ra2eSjyCG7jKZuTo1w: 2}

In the Glide table, my p1 parameter is a Joined List column with the values above. The javascript column looks like this:
Screenshot 2024-03-26 at 13.14.39

Thank you!

The JavaScript column can only return strings, not objects. If you stringify counts before returning, it should work.

Thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.