# Passing a group of DOM elements as function parameters

Now let our `setText` function take as the first parameter a reference not to single element, but to a set of elements at once:

`function setText(elems, text) { for (let elem of elems) { elem.textContent = text; } }`

Let's try out our function in practice. Suppose we have the following paragraphs:

`<p class="elem"></p> <p class="elem"></p> <p class="elem"></p> <p class="elem"></p> <p class="elem"></p>`

Let's use our function to set all these paragraphs to some text:

`let elems = document.querySelectorAll('.elem'); setText(elems, 'text');`

Make the `appendText` function that takes an array of DOM elements as the first parameter and text as the second. Make this function append text to the end of passed elements.

Make the `appendElem` function, which will take as the first parameter a reference to the DOM object that contains the `ul` tag, and as the second - the text. Make this function create a new `li` with the passed text and add it to the end of the passed `ul` tag.

Given an array and `ul`. Using the `appendElem` function created for the previous task, write each array element into a separate `li` in this `ul`.

←→
↑
en ru