Compose conditional class names
Flatten strings, nested arrays, and conditional object flags into one stable class string.Description
Requirements
The solution exports the required classNames API from the editable module.
Ignores falsy works deterministically for the documented normal, boundary, and repeated-use scenarios.
Nested arrays works deterministically for the documented normal, boundary, and repeated-use scenarios.
Object flags works deterministically for the documented normal, boundary, and repeated-use scenarios.
Preserves order works deterministically for the documented normal, boundary, and repeated-use scenarios.
Empty input works deterministically for the documented normal, boundary, and repeated-use scenarios.
Caller-owned inputs and nested values remain unchanged after the operation completes.
Mixed values
classNames('button', ['large', null], { active: true, busy: false })button large active
Falsy entries and false object flags are omitted while token order is retained.
Constraints
Support strings, arbitrarily nested arrays, objects, and falsy valuesDo not mutate arrays or objectsSeparate included tokens with one space
Hints
Hint 1
Use one recursive visitor that appends tokens to a shared output array.
Hint 2
Arrays recurse in order; objects contribute their keys when the corresponding value is truthy.
Hint 3
Filter at traversal time so the final operation is a simple join.