Created
October 8, 2017 18:58
-
-
Save pablohpsilva/60bc3142859aa1d2e4d3efd64df49bf8 to your computer and use it in GitHub Desktop.
dynamicClasses is a function that reads an object and return truthy keys as string
This file contains hidden or 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
| import { flattenObj } from '#JS/flatten' | |
| const dynamicClasses = (obj) => { | |
| if (obj && obj instanceof Object) { | |
| const flatten = flattenObj(obj) | |
| return Object.keys(flatten) | |
| .filter(el => flatten[el]) | |
| .join(' ') | |
| } | |
| return '' | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment