Skip to content

Instantly share code, notes, and snippets.

@manderly
Created July 8, 2014 17:56
Show Gist options
  • Save manderly/835e587a6950e77f9b89 to your computer and use it in GitHub Desktop.
Save manderly/835e587a6950e77f9b89 to your computer and use it in GitHub Desktop.
Code Fellows Foundations 2: preferredName() HTML Demo
<!-- Created for Code Fellows Foundations 2 as a working demonstration of preferredName()-->
<html>
<script>
var firstName = prompt("Please enter a first name: ");
var lastName = prompt("Please enter a last name: ");
var preferredName = function (firstName,lastName) {
if (firstName || lastName) {
alert( ((firstName && lastName) ? false : firstName || lastName));
} else {
alert(false);
}
};
preferredName(firstName, lastName);
//if a first name and a last name are given, return false
//if a first name OR last name is given, return that name
//if no names are given, return false
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment