Please help me fix this asap


#1

I tried to use this code for a decision game, and it doesn’t seem to work. Here is the code. Thanks!

function myGame() {
confirm(“Welcome to Lameville, officially the most boring place on Earth! There are no amusement parks, no museums, no beaches, or cool buildings. You finally decide that you have had enough, and want to explore the world…”);

do { //This begins your looped content.
var choice = prompt("You have to chose someone that you would like to go with:","Pick your FAMILY, FRIENDS, SWEETHEART, or being ALONE").toUpperCase();
}
switch (choice) {
	case 'FAMILY':
		var chance = Math.random();
		if (chance < 0.33) {
			confirm("Congradulations! You are going on a vacation to Orlando, Florida! From Dinsey World, to Universal Studios, and every other amazing attractions, you and your family will have a blast!.");
			window.open('https://drive.google.com/open?id=1OtRvir7zrMET4X8yJvRhI2D1zr73NOi9');
			// ^ Sample image from the web ^ Use this sparingly, since these images can be changed or moved/deleted at any time
		} 
		else if (chance < 0.67) {
			confirm("Aloha! The vacation you will be heading to is at Hawaii, in the United States! From here, you and your family will enjoy the natural beauty of volcanoes, beaches, the tropical setting, and the beauty of the Pacific Ocean.Sit back and relax!");
			window.open('https://drive.google.com/open?id=1LTHJG1TxtrWiPpp2iz93B5eQKlg62v7U');
			// ^ Using Google Drive Image ^ Sharing permission must be set so "Anyone with link can view" the image
		} 
		else {
			confirm("Good day, chap! You and your family will have the pleasure of seeing London, England! You will see architectural wonders, like Big Ben, Parliament, and the Buckingham Palace. Enjoy the museums, holding very valuable and beautiful items, such as the Rosetta Stone. Enjoy the peaceful countryside, and see Stonehedge. After all that sight-seeing, you can celebrate with a drink at a pub!");
			window.open('https://drive.google.com/file/d/0B_zG5YUthqXRelMxRnlETWpoREE/view?usp=sharing');
			// ^ Using Google Drive Image ^ Sharing permission must be set so "Anyone with link can view" the image
		}
		break;
	case 'FRIENDS':
		var choice2 = prompt("Would you like to have fun by chilling with your friends, or being in an excitiing rush?","Say EXCITEMENT, CHILLING, or BOTH").toLowerCase();
		if (choice2 === 'EXCITEMENT') {
			confirm("YEAH!!! You and your friends chose to experience the wild side of America, at Las Vegas! Here, you will enjoy architectural wonders of casinos, and all the excitement and sin that they offer.When you are done with gambling and shopping, enjoy food at some amazing restaurants, from famous chefs, like Gordon Ramsay or Wolfgang Puck! Remember, what happens in Vegas stays in Vegas!");
			window.open('https://drive.google.com/open?id=1yU4BZ1KZluhqRsZL7RPokBsnpEuY-DFp');
			// ^ Using Google Drive Image ^ Sharing permission must be set so "Anyone with link can view" the image
		} 
		else if (choice2 === 'CHILLING') {
			confirm("Nice! You and your friends chose to relax and hang at Miami, Florida. With beautiful beaches and the Atlantic Ocean, you can enjoy relaxing all day. Sit back, you deserve a break.");
			window.open('https://drive.google.com/file/d/0B_zG5YUthqXRelMxRnlETWpoREE/view?usp=sharing');
			// ^ Using Google Drive Image ^ Sharing permission must be set so "Anyone with link can view" the image
		} 
		else {
			confirm("Konichiwa! You chose to see the beauty of Tokyo, Japan! Japan is extremely advances in technology, such as robitics, which are becoming a larger part of people's lives. When you are tired, enjoy the beautiful beaches in Okinawa, the beauty of Mount Fuji, and the buitiful temples and shrines throughout the country, in places like Kyoto!"); 
			window.open('https://drive.google.com/open?id=1ztMeGvk8ylzhH4ERgYH8tisAttsWGflA');
			// ^ Using Google Drive Image ^ Sharing permission must be set so "Anyone with link can view" the image
		}
		break;
	case 'SWEETHEART':
		confirm("Bonjour! You chose to see the le ville de l'amour, the city of lights, Paris, France! Enjoy some beautiful architecture, like the Eiffel Tower, the Arch of Triumph, the Bastille, and everyday building architecture. See le Louvre or le Musee D'Orsay to see world famous art. Lastly, enjoy some of the best cuisine on Earth! While a unique cuisine, almost anything is worth trying!");
		window.open('https://drive.google.com/open?id=18vFZg2PtOZ7mUqzjNzXwUcRgwDrjwYiL');
		// ^ Using Google Drive Image ^ Sharing permission must be set so "Anyone with link can view" the image
		break;
	case 'ALONE':
		confirm("Take a small bite into the Big Apple, New York City! Enjoy the multitude of buildings, as well as the museums. Enjoy the Statue of Liberty, a symbol of American freedom. Experience China Town, as well as the many, yet diverse restaurants! See Times Square, a HUGE destination for shopping. With the bright lights, crazy traffic, and many people, you will truly experience the city!");
		window.open('https://drive.google.com/open?id=1Kh7kdl47kL1Tt0MLN0Ykr-0a0X3ju_nL');
		// ^ Using Google Drive Image ^ Sharing permission must be set so "Anyone with link can view" the image
		break;
	default:
		confirm("d"); //This will cause the player to loop back to the beginning of the 'do' loop.
}
var doAnother = prompt("Would you like to try again?", "YES or NO").toLowerCase();
}
while (doAnother != "no"); //This tests if doAnother has been changed, and if it's still zero, your game repeats the 'do' section.
confirm("Good bye!");

}


#2

Something to know about prompt()

prompt( "Prompt text", defaultReturnValue)

We see alot of people using the default value as a placeholder, but that is not its intended use. It should only be used if a default return value is supplied (for convenience, or to prevent empty strings on return).

prompt has two possible returns, a string (be it empty or not) or null. When it is null your code will raise an exception… null has no attribute 'toLowerCase'.

Your do..while has no exit condition (or a while) so is running an infinite loop. Set up your loop to exit on either an inputed value (say a string with some length) or on null. Change the case only if the value is a string, outside of the loop.

do {
    prompt('Enter a value from the list [FAMILY, FRIENDS, SWEETHEART, or ALONE]');
} while (choice !== "");
if (choice !== null) {
  switch (choice) {

  }
}
var doAnother ...