Assignments Class 1

Thanks for looking over my code, Cooper.  I appreciate it.

I considered a ternary operator.  And, especially considered it when I noticed that others were using it.  But, I also noticed that their function actually fails on at least one of the requirements.  And, that is when the variables are declared, but undefined as described in the following:

var FirstName, LastName; preferredName(FirstName, LastName); // -> false

I would be curious to see how you would ensure that false was returned in a compact ternary operation that would still handle this case.

Thanks,
Terry



________________________________
 From: Cooper Trowbridge <notifications@github.com>
To: codefellows/sea-c16-javascript <sea-c16-javascript@noreply.github.com> 
Cc: terrydievendorf <terrydievendorf@yahoo.com> 
Sent: 
Subject: Re: [sea-c16-javascript] Assignments Class 1 (#67)
 


In students/terrydievendorf/Assignment_2.2:
> @@ -0,0 +1,7 @@
> +// This function takes a first name and a last name and returns an exclusive or of the two names.
> +    function preferredName(firstname,lastname) {
> +      if (firstname && !lastname) return firstname;
> +      if (lastname && !firstname) return lastname;
> +      return false;
> +    }; 
This is looking great Terry! thanks for separating your test file from the actual assignment.  While this function passes the test, it can be a LOT more concise.  If you'd like to learn some more from this exercise I recommend looking at ternary operators, and how javascript evaluates || (or) to see if you can condense it on your own.
—
Reply to this email directly or view it on GitHub.