Write a JS function that scans a given HTML list and appends all collected list items’ text to a text area on the same page when the user clicks on a button.
Input/Output:
There will be no input/output, your program should instead modify the DOM of the given HTML document.
Sample HTML:
<ul id="items">
<li>first item</li>
<li>second item</li>
<li>third item</li>
</ul>
<textarea id="result"></textarea>
<br>
<button onclick="extractText()">Extract Text</button>
<script>
function extractText() {
// TODO
}
</script>
Examples: