Skip to content

Instantly share code, notes, and snippets.

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