Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a text file named string.js and enter the Capitalize function into that f

ID: 3569932 • Letter: C

Question

Create a text file named string.js and enter the Capitalize function into that file. Then modify your strdemo.html page so that it loads this library file. When the button in the page is clicked, in addition to displaying the pervious values, it should also call the Capitalize function and display capitalized word in the page. Once you have done this, test the page using various string inputs to verify that the function produces the desired results. How does the function behave when given a string containing characters other than letter (e.g. digits,spaces,punctuation marks)? Explain observations.

code to work with:

http://pastebin.com/3299gMTP

Here's a picture of the page, the js library, and what the web console says about the page.

html> !doctype 2 !-- atdemo.html !This page demonstrates several string properties and operations -> Khtml 7 Khead> 10 function Process ( // Assumes: strBox contains a string // Results: displays the outcome of string operations in outputDiv 12 13 14 15 16 17 18 19 20 21 var 3tr strdocument.getElementById ('strBox.value document.getElementById ('outputDiv) .innerHTML - length:+ str.length + uppercase: + str.toUpperCase) +'lowercase:'+ str.toLowerCase + '': 23 2 4 25 26 27 28 29 30 31 32 String Demo xp> id="strBox" size=20 value=""> Enter a string : input type="button" value= "Click to 3 4 Process"> 36 37 38 L Hyper Text Markup Lans length 1140 ines: 38 Ln: 27 Col: 10 Sel: 010 Dos Windows UTF-8 w/o BOM INS

Explanation / Answer

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> String Demo </title>
<script type="text/javascript" src="string.js"></script>
<script type="text/javascript">
function Process()
// Assumes: strBox contains a string
// Results: displays the outcome of string operations in outputDiv
{
var str;

str = document.getElementById('strBox').value;

document.getElementById('outputDiv').innerHTML =
'length: ' + str.length + '<br>' +
'uppercase: ' + str.toUpperCase() + '<br>'
+ 'lowercase: ' + str.toLowerCase() + '<br>'
+ 'Capitalize: ' + Capitalize() + '<br>';
}


</script>
</head>

<body>
<h2>String Demo</h2>
<p>
Enter a string: <input type="text" id="strBox" size=20 value="">
</p>
<input type="button" value="Click to Process">
<hr>
<div id="outputDiv"></div>
</body>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote