Skip to content

Instantly share code, notes, and snippets.

@pablohpsilva
Created October 8, 2017 18:58
Show Gist options
  • Select an option

  • Save pablohpsilva/60bc3142859aa1d2e4d3efd64df49bf8 to your computer and use it in GitHub Desktop.

Select an option

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
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