SyntaxFix
Write A Post
Hire A Developer
Questions
Before each of your conditional statements, you could do something like this:
var pagetype = pagetype || false; if (pagetype === 'something') { //do stuff }