I imagine this is really simple but I just seem unable to achieve it. I have this snippet...
var choice = location.href.split("?")[1].split("=")[1];
It works fine until 'choice' is empty, then it throws the following error....
TypeError: location.href.split(...)[1] is undefined
I understand this is because you cant call split on a variable that is undefined, my solution i think is to store the variable and then split it if full or ignore it if undefined.
Can someone help me do this?