Skip to content

Instantly share code, notes, and snippets.

@juanchaves
Created November 29, 2016 00:59
Show Gist options
  • Select an option

  • Save juanchaves/66f2848a4b5a6c66c2dd1fb16be5b3e5 to your computer and use it in GitHub Desktop.

Select an option

Save juanchaves/66f2848a4b5a6c66c2dd1fb16be5b3e5 to your computer and use it in GitHub Desktop.
Juan Chaves
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>Which Side are You?</h1>
<p></p>
<script>
var username = prompt('What is your name?');
console.log('The user\'s name is ' + username);
alert('Amazing to meet you, ' + username);
var hometown = prompt('Where are you from?');
console.log('The user is from' + hometown);
var lightOrDarkSide = prompt(username + ': Do you choose the light or dark side?').toUpperCase();
console.log('The user chose the ' + lightOrDarkSide);
switch(lightOrDarkSide)
{
case 'LIGHT':
alert('So, you chose the ' + lightOrDarkSide.toLowerCase() + ' side ... welcome Master ' + username + ' !');
console.log('The user\'s name is Master ' + username);
break;
case 'DARK':
alert('So, you chose the ' + lightOrDarkSide.toLowerCase() + ' side ... welcome Darth ' + username + ' !');
console.log('The user\'s name is Darth ' + username);
}
if (lightOrDarkSide === 'LIGHT')
{
alert('Choose a padawan');
var padawan = prompt ('What is your padawan\'s name?');
console.log('The user\'s padawan is ' + padawan);
alert('So, Master ' + username + ' you chose ' + padawan + ' as your padawan!');
document.write('Your name is Master ' + username + ' from '+ hometown);
document.write('You chose the: ' + lightOrDarkSide.toLowerCase() + ' side and you chose: ' + padawan +' as your padawan!');
}
else
{
alert ('Choose an apprentice')
var apprentice = prompt('What is your apprentice\'s name?');
console.log('The user\'s apprentice is ' + apprentice);
alert('So, Darth ' + username + ' you chose ' + apprentice + ' as your apprentice!');
document.write('Your name is: Darth' + username + ' from ' + hometown);
document.write('You chose the: ' + lightOrDarkSide.toLowerCase() + ' and you chose: ' + apprentice +' as your apprentice!');
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment