Project #3                                                    Passport (Intermediate)


Objective

To practice functions, arrays, and iteration statements. 

Overview

For this project you will write two functions named readNumberOfEntries and isPalindrome, that are part of the program available in palindrome.html.txt.  Notice that you will need to rename the file to palindrome.html in order to run the script.  A description of each function is provided below.

Specifications

  1. readNumberOfEntries - This function will ask the user for a value greater than or equal to two.  The function will keep asking values as long as the user provides a value less than two. For each incorrect value the function will print (using alert) the message

                                    "Error: Number must be greater than or equal to 2"

       

         The function will end once a correct value is provided (the function returns this value). 

 

  1. isPalindrome - This function will verify whether a set of values represent a palindrome.  We define a palindrome as a set of entries that when read from left to right and from right to left, present the same set of values.  For example, the following are considered palindromes:

            Example1:             dog    cat    dog

            Example2:             10    20    10

            Example3:             10    10

            Example4:             John   20    John

            Example5:             10    5    5    10

 

          The following are not considered palindromes:

 

            Example1:             dog    cat    cat

            Example2:             10    20    8

            Example3:             10    20

            Example4:             John   20    JOHN

The function will read a set of values from the user and will return true if the set of values represents a palindrome, and false otherwise.  You must use the readNumberOfEntries function described above in order to read the number of entries the user will provide. The actual entries are read by the isPalindrome function.

Requirements


Submission

To submit your project e-mail the palindrome.html as an attachment in a single e-mail message to cllewis@umd.edu Make sure you write your name on the message you send and that you use as subject "Passport Intermediate Project #3".