I'm having problems declaring the current route the end user is in
Greetings if in that line you say undefined is that at no time is declared, in addition to what I see these using JQuery then your code should be as an example as follows:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<script>
$(document).ready(function(){
console.log("Hola Mundo");
})
</script>
</body>
</html>
Note that at the beginning I declare the library that I occupy that as notes you are using the dollar sign $ that is indicative of JQuery.
Always go first to the library you use and then your code written by yourself