title: How do I get user to input two last names and have Javascript spit out which one comes first alphabetically?
body: <p>I have an assignment for Javascript class. The basis of the assignment is to use the if/else if statements to set up the script. I've read and re-read the assignment and I don't understand how to get the names (user input) in alphabetical ordering. Please help!My instructor and book are useless! Here are the instructions:</p>
  
  <p>Write the JavaScript code in one HTML document using IF, and IF/Else statements for the following three situations. For each one make sure to write comments for each section.</p>
  
  <p>B. Check for the alphabetical order of names.</p>
  
  <p>(See ASCII table at <a href="http://www.asciitable.com/" rel="nofollow">http://www.asciitable.com/</a> to confirm)</p>
  
  <p>Variable declarations section
  1. Declare a variable that holds a person’s last name.
  2. Declare a variable that holds a second person’s last name.</p>
  
  <p>Assignments section
  3. Ask the user to enter their last name.
  4. Ask the user to enter the last name of a friend.</p>
  
  <p>Logic and Output section
  5. Use only variables in your logic.
  6. Determine which name is first in the ascending sequence of the alphabet.
  7. Display the message “Your last name is before/after mine in the alphabet.”</p>
  
  <p>Testing: Try names that have the same first letter. Compare names where one begins with a small letter and the other a capital letter. Compare names that are close with one letter different like: Anderson and Andersen.</p>
  
  <p>My code thus far:</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
  
          // Variable declarations
  
              var userLast1;          
              var userLast2;
  
         // Assignments
  
          userLast1 = prompt("Please enter your last name.");
          userLast2 = prompt("Please enter the last name of a friend.");
  
         // Calculations &amp; output
  
         if (userLast1 &gt; userLast2)
         {
         alert("Your last name comes before your friend's in the alphabet.");
         }
         else if (userLast2 &gt; userLast1)
         {
         alert("Your friend's last name comes before your's in the alphabet.");
         }
         else
         {
         alert("You and your friend have the same last name.");
         }
  
  
      &lt;/script&gt;
  </code></pre>