Skip to content

Instantly share code, notes, and snippets.

@paigen11
Last active September 15, 2019 00:55
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 paigen11/b1bb276b2bfe2bbb5e036def191e17be to your computer and use it in GitHub Desktop.
Save paigen11/b1bb276b2bfe2bbb5e036def191e17be to your computer and use it in GitHub Desktop.
Creating a configurable string via ES6 nested template strings
function isDesktopSize(){
window.innerWidth > 1400 ? true : false;
}
var navbar = {
isOpen: true
};
classes = `header ${ isDesktopSize() ? '' :
`icon-${navbar.isOpen ? 'collapse' : 'expand'}` }`;
console.log(classes);
// prints: header icon-collapse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment