I know there are longer ways of doing this, but I have an attribute on a button (aria-expanded) and I’m trying to convert that string to a boolean and then have it toggle from false to true, and vice versa.
Is the aria-expanded a string, or a number?
!(!!string) doesn’t work; or rather, it evaluates anything that isnt the empty string as true. (“false” is truthy.)
Mateus’ code is probably the closest you’ll get, except it needs to negate the condition: if “true”, it needs to evaluate as false.