Skip to content

Instantly share code, notes, and snippets.

@intrnl
Created July 11, 2019 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save intrnl/e152964c3c750395d9f67533bda85aee to your computer and use it in GitHub Desktop.
Save intrnl/e152964c3c750395d9f67533bda85aee to your computer and use it in GitHub Desktop.
function classnames (...classes) {
const arr = []
for (const name of classes) {
if (typeof name === 'string') {
arr.push(name)
}
else if (typeof name === 'object' && name !== null) {
for (let [key, value] of Object.entries(name)) {
if (value) arr.push(key)
}
}
}
return arr.join(' ')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment