Write a page that lets us perform various manipulations on the text in a text area. Here is the page (click the image to run our sample solution, written by TAs Sylvia Tashev and Stefanie Hatcher):
The HTML and CSS are already written, but we must add JavaScript code to make the UI respond when the user clicks the buttons. Start from the skeleton orderit.html.
Add the following behavior to the buttons:
document.getElementById
function.
split
method to break it into an array of smaller strings.
length
field and methods such as:
concat
,
join
,
pop
,
push
,
reverse
,
shift
,
slice
,
sort
,
splice
, and
unshift
.
More Behavior to add:
shuffle
method for arrays, but you can
write one using the following algorithm:
for each index i:
randomly choose an index j >= i.
swap lines i and j.
If you finish all of that behavior, consider adding a button to change the capitalization of lines, such as capitalizing/lowercasing entire lines or converting lines to AlTeRnAtInG cAsE.