"use strict";

$(".nav a").on("click", function(){
   $(".nav").find(".active").removeClass("active");
   $(".nav").find(".active-re").removeClass("active-re");
   $(this).parent().addClass("active");
   $(this).parent().addClass("active-re");
});

var hash = location.hash;
if(hash!==""){
var a = $("a[href="+hash+"]");
$(".nav").find(".active").removeClass("active");
$(".nav").find(".active-re").removeClass("active-re");
a.parent().addClass("active");
a.parent().addClass("active-re");
}
$('.nav a').on('click', function(){
   if($(".navbar-toggle").is(":visible")){
    $(".navbar-toggle").click();
   }
   });

"use strict";

var $navLinks = $(".nav a"),
    $nav = $(".nav");

$navLinks.on("click", function(){
    // Toggle active link in nav
    $nav.find(".active").removeClass("active");
    $nav.find(".active-re").removeClass("active-re");
    $(this).parent().addClass("active active-re");

    // Hide navbar toggle if visible
    var $navbarToggle = $(".navbar-toggle");
    if ($navbarToggle.is(":visible")) {
        $navbarToggle.click();
    }
});

var hash = location.hash;

if (hash !== "") {
    var $a = $("a[href="+hash+"]");
    $nav.find(".active").removeClass("active");
    $nav.find(".active-re").removeClass("active-re");
    $a.parent().addClass("active active-re");
}

Clean up js code (multiple DOM traversals/event listeners, indentation)
Clean up js code (multiple DOM traversals/event listeners, indentation)
