How to get a Sticky header on website using Javascript?

Tried to get a sticky header onto my website using javascript, but doesn’t seem to be working. Here is the html code and javascript related to this section:

<a href="#" …