I have a bunch of collapsed text elements inside of a column, and I’d like to expand all the text elements whose ID ends with “bg”. So I’m first trying to get an array of the column’s children, then filter that array based off the ending portion of each element’s ID.
Here’s how I’m trying it.
I’m currently testing this by console logging “bgTexts” and checking the console to see if the array has anything in it. So far it seems that my filter always filters out everything no matter how I format the “endsWith” portion.
Also I’m a total n00b so any help is much appreciated!
(also, I couldn’t get a proper code snippet to post; “account not allowed to post links” or some such. Is that normal?)
What’s the parent component here? A strip column? A table column? Or what?
And yes, it’s completely normal, only admins and moderators can include links in their posts/replies/answers.
Hope this helps~!
the parent is a strip column.
@Ahmad I just figured out my issue. the “endsWith” is case sensitive. I read in the API reference that “endsWith” isn’t case sensitive, but maybe that’s just when doing a query as opposed to a filter?
@spencerbeebe Not it’s always case sensitive, if you want it to ignore the case sensitivity, just set all of them to lower case, here’s how:
const filtered = array.map(item => item.id.toLowerCase().endsWith('bg'));
Hope this helps!~