Adjacent insertion of elements in JavaScript

insertAdjacentElement
Задание 1

Given an element:

html<div id="elem" style="border: 1px solid red;">
  <p>text</p>
  <p>text</p>
  <p>text</p>
</div>

Insert a paragraph with the text '!!!' before it.

Задание 2

Given an element:

html<div id="elem" style="border: 1px solid red;">
  <p>text</p>
  <p>text</p>
  <p>text</p>
</div>

Insert a paragraph with the text '!!!' after it.

Задание 3

Given an element:

html<div id="elem" style="border: 1px solid red;">
  <p>text</p>
  <p>text</p>
  <p>text</p>
</div>

Insert a paragraph with the text '!!!' at the beginning of it.

Задание 4

Given an element:

html<div id="elem" style="border: 1px solid red;">
  <p>text</p>
  <p>text</p>
  <p>text</p>
</div>

Insert a paragraph with the text '!!!' at the end of it.