Basically the question is self explanitory. I can't figure out how to combine small snippets of javascript rather than having two separate files.

The two codes are :

```
$(function(){
    $('.navbar li').each(function(){
      if(window.location.href.indexOf($(this).find('a:first').attr('href'))>-1)
        {
      $(this).addClass('active').siblings().removeClass('active');
        }
    });
});

$(function(){
    $('.dropdown-menu li').each(function(){
      if(window.location.href.indexOf($(this).find('a:first').attr('href'))>-1)
        {
      $(this).removeClass('active')
        }
    });
});

```

Another question, is the first `$(function()` necessary?

Thanks for you help.