Created
July 8, 2014 17:56
-
-
Save manderly/835e587a6950e77f9b89 to your computer and use it in GitHub Desktop.
Code Fellows Foundations 2: preferredName() HTML Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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