title: Pass arrays in function
body: <p>I created a function but then realised I had to call it three times with two different parameters so I decided to create two different arrays and modify the function so it is called once. After modifiying the function it doesn't work so I am not sure what is happening. Here it is:</p>
  
  <pre><code>function scrll(selector,speed){
                  for (var i = 0; i &lt; selector.length; i++){
                      var findIt = '.find("a")';
                      var selected = selector[i];
                      selected += findIt;
                      selected.click(function(e) {
                          e.preventDefault();
                          var section = $(this).attr("href");
                          $("html, body").animate({
                              scrollTop: $(section).offset().top - 54
                          },speed[i]);
                      });
                  };
              };
  var selector = ['$(".navbar")','$(".click")','$("#foot")'];
              var speed = [2000,1000,2000];
              scrll(selector,speed);
  </code></pre>
  
  <p>Here is a jsfiddle example: <a href="http://jsfiddle.net/theMugician/31fws6kd/16/" rel="nofollow">http://jsfiddle.net/theMugician/31fws6kd/16/</a></p>