Created
July 11, 2019 08:33
-
-
Save intrnl/e152964c3c750395d9f67533bda85aee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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