Skip to content

Instantly share code, notes, and snippets.

@konamax123 konamax123/nav.js
Last active Jan 4, 2017

Embed
What would you like to do?
route switch statement
const fullLink = '/advertisers/accounts';
const route = '/advertisers/accounts/create';
const accountId = '1234a';
console.log(route === `${fullLink}/create`) // => true
let isActive;
switch (route) {
case route === fullLink:
isActive = true;
break;
case route === `${fullLink}/create`:
isActive = true; // should match this and set isActive to true
break;
case route === `${fullLink}/${accountId}`:
isActive = true;
break;
default:
isActive = false; // only hitting default case and keeping isActive as false
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.