Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. image text in transcribed 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 );

7 messenger-vahoosea M messenger. Yahoo Sea 45 Chapta_Part1.pdf Architectural styles pdf asg3.pdf O file:///C .fall%202017/soen%20287/SOEN287-Fall2017 Assignment 3.pdf re is a sample outout to illustrate the ex ed behavior of y am dit View History Enter some text: A profeTalsb teaches three courses in this winter term Enter a character to search for Search Results 6 occurrence(s) of't found File Edit Yew History Bookmarks lools elp Enter some text Enter a character to search for 7 Results 3 occurrence(s) of7 found Search O Type here to search ENG 4:48 PM US 2017-10-29

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

n=int (xlogb)+1 find the number of digits in 2^(350)

Answered: 1 week ago