Return to the project05-04.js file in your code editor. Create a for loop that uses a counter variable,

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%
Return to the project05-04.js file in your code editor. Create a for loop that uses a counter variable, i, to
loop through all the items in phrases node list. For each phrases[i] item in that list, apply an onclick
event handler that runs an anonymous function. Add the statements described in Steps 4 through 10 to that
anonymous function.
Transcribed Image Text:Return to the project05-04.js file in your code editor. Create a for loop that uses a counter variable, i, to loop through all the items in phrases node list. For each phrases[i] item in that list, apply an onclick event handler that runs an anonymous function. Add the statements described in Steps 4 through 10 to that anonymous function.
1
<!DOCTYPE html>
2
<html>
<head>
4
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Hands-on Project 5-4</title>
6.
7
<link rel="stylesheet" href="styles.css" />
<script src="footnotes.js " defer></script>
8
9
<script src="project05-04_txt.js" defer></script>
</head>
10
11
12
<body>
<header>
13
14
15
<h1> Hands-on Project 5-4 </h1>
16
</header>
17
<article>
<h2>Hamlet, Act II Scene ii</h2>
<blockquote>
18
19
20
<h3>Hamlet</h3>
<p>0, what a rogue and <dfn>peasant slave</dfn> am I!<br>
Is it not <dfn>monstrous</dfn> that this player here,<br>
21
22
23
But in a fiction, in a dream of passion,<br>
Could force his soul so to his own <dfn>conceit</dfn> <br>
24
25
That from her working all the visage <dfn>wann'd</dfn> <br>
Tears in his eyes, distraction in his <dfn>aspect</dfn> <br>
A broken voice, an' his whole function suiting<br>
26
27
28
With forms to his conceit? And all for nothing,
</p>
<p>For <dfn>Hecuba</dfn>!
29
30
What's Hecuba to him, or he to Hecuba<br>
That he should weep for her? What would he do<br>
31
32
33
Had he the motive and the <dfn>cue</dfn> for passion<br>
That I have? He would drown the stage with tears,<br>
And cleave the general ear with horrid speech,<br>
34
35
Make mad the guilty, and appall the free,<br>
Confound the ignorant, and amaze indeed<br>
The very faculties of eyes and ears.
36
37
38
</p>
<p>Yet I,
39
40
A dull and <dfn>muddy-mettled</dfn> rascal, peak<br>
Like John-a-dreams, <dfn>unpregnant of my cause</dfn>,<br>
And can say nothing; no, not for a king,<br>
41
42
43
Upon whose property and most dear life<br>
A damn'd defeat was made. Am I a coward?
44
45
46
</p>
<p>Who calls me villain, breaks my <dfn>pate</dfn> across, <br>
Plucks off my beard and blows it in my face,<br>
Tweaks me by the nose, <br>
47
48
49
50
gives me the lie i' th' throat <dfn>as deep as to the lungs?</dfn><br>
51
Who does me this? <br>
52
Hah, <dfn>'swounds</dfn>, I should take it; for it cannot be<br>
But I am <dfn>pigeon-liver'd</dfn>, and lack gall.
</p>
53
54
<p>To make oppression bitter, or <dfn>ere</dfn> this<br>
I should 'a' fatted all the <dfn>region kites</dfn><br>
With this slave's <dfn>offal</dfn>. Bloody, bawdy villain!<br>
55
56
57
58
Remorseless, treacherous, lecherous, <dfn>kindless</dfn> villain!<br>
Why, what an ass am I! This is most brave, <br>
That I, the son of a dear father murthered,<br>
Prompted to my revenge by heaven and hell,<br>
Must like a whore unpack my heart with words,<br>
59
60
61
62
63
And <dfn>fall a-cursing</dfn> like a very <dfn>drab</dfn>,<br>
A <dfn>scullion</dfn>. Fie upon't, foh! <dfn>About, my brains!</dfn>
64
65
</p>
<p>Hum-I have heard<br>
66
67
That guilty creatures sitting at a play<br>
68
Have by the <dfn>very cunning of the scene</dfn><br>
69
Been strook so to the soul, that presently<br>
They have proclaim'd their malefactions:<br>
For murther, though it have no tongue, will speak<br>
70
71
With most miraculous organ. I'll have these players<br>
Play something like the murther of my father<br>
Before mine uncle. I'll observe his looks,<br>
72
73
74
75
<dfn>I'll tent him to the quick</dfn>. If 'a do <dfn>blench</dfn>, I know my course.
76
</p>
Transcribed Image Text:1 <!DOCTYPE html> 2 <html> <head> 4 <meta charset="utf-8" /> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>Hands-on Project 5-4</title> 6. 7 <link rel="stylesheet" href="styles.css" /> <script src="footnotes.js " defer></script> 8 9 <script src="project05-04_txt.js" defer></script> </head> 10 11 12 <body> <header> 13 14 15 <h1> Hands-on Project 5-4 </h1> 16 </header> 17 <article> <h2>Hamlet, Act II Scene ii</h2> <blockquote> 18 19 20 <h3>Hamlet</h3> <p>0, what a rogue and <dfn>peasant slave</dfn> am I!<br> Is it not <dfn>monstrous</dfn> that this player here,<br> 21 22 23 But in a fiction, in a dream of passion,<br> Could force his soul so to his own <dfn>conceit</dfn> <br> 24 25 That from her working all the visage <dfn>wann'd</dfn> <br> Tears in his eyes, distraction in his <dfn>aspect</dfn> <br> A broken voice, an' his whole function suiting<br> 26 27 28 With forms to his conceit? And all for nothing, </p> <p>For <dfn>Hecuba</dfn>! 29 30 What's Hecuba to him, or he to Hecuba<br> That he should weep for her? What would he do<br> 31 32 33 Had he the motive and the <dfn>cue</dfn> for passion<br> That I have? He would drown the stage with tears,<br> And cleave the general ear with horrid speech,<br> 34 35 Make mad the guilty, and appall the free,<br> Confound the ignorant, and amaze indeed<br> The very faculties of eyes and ears. 36 37 38 </p> <p>Yet I, 39 40 A dull and <dfn>muddy-mettled</dfn> rascal, peak<br> Like John-a-dreams, <dfn>unpregnant of my cause</dfn>,<br> And can say nothing; no, not for a king,<br> 41 42 43 Upon whose property and most dear life<br> A damn'd defeat was made. Am I a coward? 44 45 46 </p> <p>Who calls me villain, breaks my <dfn>pate</dfn> across, <br> Plucks off my beard and blows it in my face,<br> Tweaks me by the nose, <br> 47 48 49 50 gives me the lie i' th' throat <dfn>as deep as to the lungs?</dfn><br> 51 Who does me this? <br> 52 Hah, <dfn>'swounds</dfn>, I should take it; for it cannot be<br> But I am <dfn>pigeon-liver'd</dfn>, and lack gall. </p> 53 54 <p>To make oppression bitter, or <dfn>ere</dfn> this<br> I should 'a' fatted all the <dfn>region kites</dfn><br> With this slave's <dfn>offal</dfn>. Bloody, bawdy villain!<br> 55 56 57 58 Remorseless, treacherous, lecherous, <dfn>kindless</dfn> villain!<br> Why, what an ass am I! This is most brave, <br> That I, the son of a dear father murthered,<br> Prompted to my revenge by heaven and hell,<br> Must like a whore unpack my heart with words,<br> 59 60 61 62 63 And <dfn>fall a-cursing</dfn> like a very <dfn>drab</dfn>,<br> A <dfn>scullion</dfn>. Fie upon't, foh! <dfn>About, my brains!</dfn> 64 65 </p> <p>Hum-I have heard<br> 66 67 That guilty creatures sitting at a play<br> 68 Have by the <dfn>very cunning of the scene</dfn><br> 69 Been strook so to the soul, that presently<br> They have proclaim'd their malefactions:<br> For murther, though it have no tongue, will speak<br> 70 71 With most miraculous organ. I'll have these players<br> Play something like the murther of my father<br> Before mine uncle. I'll observe his looks,<br> 72 73 74 75 <dfn>I'll tent him to the quick</dfn>. If 'a do <dfn>blench</dfn>, I know my course. 76 </p>
Expert Solution
Step 1

You can do something like this.

 

-------------------------------------------------------- JavaScript Code-----------------------------------------------------

for ( var i = 0; i < phrasesList.length; i++ )

function myFunction(i){ 
  phrasesList[i].onclick = myFunction(() {
      // write the anonymous function here
  }
})

(i);

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY