Choose Your Own Adventure


#1

Does anyone have any insight on why my code isn't working? When I un-comment the switch statement, my alert & prompt no longer work. userAnswer should be a global variable so being outside the curly braces of the .click(function) should be fine correct? Thanks for any help you can offer.

$(document).ready(function(){
	alert("Are you read to become the next president of the United States of America?");
	$('.button').click(function(){
		var userAnswer = prompt("Which primary leading candidate would you like to be? Hillary Clinton, Bernie Sanders, Marco Rubio or Donald Trump?").toUpperCase();
	});
	// switch(userAnswer) {
 //    	case 'HILLARY CLINTON':
 //        	console.log("Welcome to Election 2016 Senatory Clinton.");
 //       		break;
 //    	case 'BERNIE SANDERS':
 //        	console.log("Welcome to Election 2016 Senatory Sanders.");
 //        	break;
 //    	case 'MARCO RUBIO':
 //        	console.log("Welcome to Election 2016 Senatory Rubio.");
 //        	break;
 //    	case 'DONALD TRUMP':
 //    		console.log("Welcome to Election 2016 Mr. Trump.");
 //    		break;
 //    	default:
 //        	console.log("I don't think that's an option.");
};