Web APIs & Utilities

Implement classNames Utility

easyJS SpecificJS / TS3 tests

Problem Statement

Implement a `classNames(...args)` helper (similar to clsx or classnames) that conditionally joins CSS class names together. Handles strings, numbers, arrays, and objects with truthy/falsy values.

Examples

Example 1:
classNames('btn', { 'btn-primary': true, 'btn-disabled': false }); // 'btn btn-primary'

Example 2:
classNames('a', ['b', { c: true, d: false }], null, undefined, 0); // 'a b c'
JavaScript & TypeScript starter code included
Run this as a live interview

Practice solo

3 test cases. No second person needed.

Get new interview exercises

Practice problems and review drills, sent when we publish new ones. No spam.

Unsubscribe anytime. We never share your address.