-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsonnetScript.js
More file actions
24 lines (18 loc) · 864 Bytes
/
Copy pathsonnetScript.js
File metadata and controls
24 lines (18 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
1. Take the contents of the sonnet div and place it in a variable
2. Find and output the starting position of the word "orphans"
3. Output the number of characters in the sonnet
4. Replace the first occurance of the string "winter" with "yuletide"
5. Replace all occurances of the string "the" with "a large"
6. Set the content of the sonnet div with the new string
*/
var sonnetElement = document.getElementById("sonnet");
var sonnetText = sonnetElement.innerHTML;
console.log("sonnetText", sonnetText);
var indexOfOrphans = sonnetText.indexOf("orphans");
console.log("indexOfOrphans", indexOfOrphans);
console.log("length of sonnet", sonnetText.length);
sonnetText = sonnetText.replace("winter", "yuletide");
console.log(sonnetText);
sonnetElement.innerHTML = sonnetText;
sonnetElement.innerHTML = sonnetText.replace(/the/g, "a large");