Question: Question #1 Write a JavaScript script called CharacterOccurences.JS that inputs several lines of text and a search character and uses String method indexOf() to determine
Question #1
Write a JavaScript script called "CharacterOccurences.JS that inputs several lines of text and a search character and uses String method indexOf() to determine the number of occurrences of the character in text.
A) You have to use the external CSS file called "CharacterOccurences.CSS" to set the margin of the paragraph to the value 0 (zero).
B) You have to declare in your HTML form four (04) ids :
a. "searchString" as textarea id in paragraph with 4 rows and 55 columns
b. "characters" as input id in paragraph with text type and size equal 5
c. "searchButton" as input id in paragraph with button type and its value equal "Search"
d. "output" as id in paragraph is for the final result.
C) The JavaScript file (CharacterOccurences.js) contains three (03) global variables and two (02) functions:
a. Global variables :
i. searchStr to get the id of "searchString"
ii. ch to get the id of "characters"
iii. outResult to get the id of "output"
b. The function getAllDomElement() that
i. Accesses the "searchButton" element and adds the search button using its id by using the existing the function addEventListener(), which takes three (03) arguments: (a) the name of event as a string literal (here is "click"), (b) the function searchOccurrences, and (c) the Boolean value false.
ii. Gets all id elements of "searchString", "characters", "output" using the existing function getElementById()
c. The function searchOccurrences() to search the character we look for and count the number of occurrences of that character.
i. 4 local variables: count, chValue, searchStr, result.
ii. Use the functions: charAt( 0 ), toLowerCase() and indexOf().
iii. If the variable count equal 0 (zero) display the message: the character ch not found. Otherwise display the result.
D) At the end of the JavaScript file, finish with this line to fire the load event when a resource and its dependent resources have finished loading:
window.addEventListener( "load", getAllDomElement, false );

soEN 287 winter 2017 x C file:/IC Users/John/AppData/Local/Packages/microsoft windowscommunicationsapps 8wekyb3d8bb State/Files/S0/1026/SOEN287 wint m we/Local Here is a sample output to illustrate the expected behavior of your program File Edit View History Bookmarks Iools Help Enter some text: professor Taleb teaches three courses in this winter term. Enter a character to search for: Search Results 6 occurrence(s) of t found File Edit View History Bookmarks Iools Help Enter some text: Enter a character to search for: 7 Search Results 3 occurrence(s) of 7 found O Ask me anything 12:32 AM 2017-03-17
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
