Find the name and create a list. How?

Find the name and create a list. How?

Hello,  I'm starting to learn javascript and jquery and I would do something like this:

1. The script finds all the headings in html (<h1></h1>).
2. Creates a list of titles of these headers.
3. The list has a specific css and the maximum length of text.
4. Each name from the list has (<a href="">name</a>) is a link to the title.

  1. $(document).ready(function() {
  2. $('h1');
  3. $('.left li').addClass('button');
  4. });
  5. ...?

please help...