MIS 3371 Parks Exam 1 Summer 2018

.
1. (50 points) The Top 100 Mystery Novels of All Time chosen by Mystery Writers of America is shown to the left in a form named f1 and a textarea named ta1. There are three pieces of information for each novel:
  1. title followed by a "*"
  2. author followed by a "*"
  3. rank followed by a "#" (except the last one)
Assume the following two arrays are defined in p1:
  1. var authors = ["Agatha Christie","Dashiell Hammett","Dorothy L. Sayles", "Graham Greene","Raymond Chandler","John Grisham"];
  2. var counts = [0, 0, 0, 0, 0, 0];
Write the javascript function named p1 that:
  1. retrieves the data from the textarea ta1
  2. creates a 100 row by 3 column table showing in the column data in the following order (left to right):
    1. rank
    2. title
    3. author
  3. following the table, display the author names and counts for each of the six novelists stored in the array named authors (i.e., count and display the names and the number of times each of the six authors appear on the list)
  4. place the resulting table and six author's names and counts in the DIV block whose id="p1_out"
this is the DIV block with id="p1_out"

Do not make a heading row for the table. Show NO HTML. Show only the javascript for p1.

Declaration of Independence

Search Value

2. (50 points) The Declaration of Independence of July 4, 1776 is shown to the left in the textarea named ta2 in a form named f2. It is separated into 59 lines of text. The lines are separated by the "*" character. There is also a textbox named sv where the user enters a search value. Write the user presses "Execute p2" button, the javascript function p2:
  1. retrieves the text of the Declaration of Independence from ta2
  2. splits value of ta2 on the "*" character into an array named dec
  3. sets the string named os to an empty string
  4. retrieves the value of sv and stores it in the javscript as search_val
  5. sets the line counter named lc to zero
  6. searches for the search_val in the array dec. If found:
    1. add a <p> tag to os
    2. add the line number in dec to os where search_val appears
    3. add the element of dec that contains search_val to the string os
    4. increment lc by one to count the lines that contain search_val
  7. after the search has been completed, in the string os replace all occurrences of search_val with:
         "<b>" + search_val.toUpperCase() + "</b>"
  8. display os and the value of lc in p2_out

Show NO HTML. Show only the javascript for p2.

 
this is the DIV with id="p2_out_"