How to turn the header text into a link using JS?

How to make. when you click on the link, the title with the class .maintitle were substituted in the end of the path in the link and passed on it?

<h1 class="maintitle">Art Museum</h1>
<a class="map-link" href="https://yandex.ru/maps/krasnodar/"></a>
April 19th 20 at 12:39
1 answer
April 19th 20 at 12:41
Solution
  1. Hang an event handler "click" on the appropriate link
  2. In the handler:
    1. To find the item .maintitle
    2. To obtain the text (or any property)
    3. To alter the href from clicked links

  3. If no handler canceled the default action the browser will continue to process the link will go on the changed URL

Find more questions by tags JavaScript