Having trouble getting a counter reset function to work using sockets in express

I have a project I am working on for a coding bootcamp. For the project I need to create a website that has a button that when pressed adds +1 to a counter and displays how many times the button has been pressed. The project also needs a reset button that when pressed resets the count back to zero.

I created the project and everything is working well except for the reset function. Whenever I press the reset button nothing happens. I have looked over the code and I don’t see any errors in the reset function that I wrote. Could anyone out there give me any tips on something I may be overlooking as a newbie coder?

Here is my index.js page:

module.exports = function Route (app, server) {
    // this gets the socket.io module (below)
    var io = require("socket.io").listen(server)

    var counter = 0; //saves the count

    io.sockets.on("connection", function(socket){
        socket.on("push_button", function(data){
            counter +=1;
            io.emit("push_counter", {response: counter}); 
            /* io.emit is a full broadcast, thus sends data to all connectd clients
            will send counter number to index.ejs after increasing by 1 */
        })

        socket.on("reset_counter", function(data){
            counter = 0;
            io.emit("reset_response", {response: counter});
            /* Will set counter to 0 and send to index.ejs */

        })
    })




    // root route to render the index.ejs view (below)
    app.get("/", function(request, response){
        response.render("index");
    })
};

Here is my index.ejs file that I have stored in a views folder. This page contains the reset function:

<!DOCTYPE HTML>
<html lang ="en US">
<head>
    <meta charset="UTF-8">
    <title>Epic Button Game</title>
    http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
    /socket.io/socket.io.js
    
        $(document).ready(function (){
           // alert("jquery loaded");
           var socket = io.connect();

          //lets emit an event when somebody pushes the button
          $("#push").click(function(){
                socket.emit("push_button", {action: "Somebody pushed the button"});
          });

          // this event will emit to the server to reset the counter into 0
            $('#reset').click(function(){
                socket.emit("reset_counter", {action: 'Resetting the counter'});
            });

          // listen to the push_counter event from server
          socket.on("push_counter", function (data){
             console.log(data); // 
</head>
<body>
    <center>
        <h2 id="message">Reset needs to be fixed!</h2>
        <h4>Push the button to update the count!</h4>
        <button id="push">Push this awesome button</button>
        <button id="reset">Reset Count</button>
    </center>
</body>
</html>

Here is my server.js page:

// require express, path, body-parser
var express = require("express");
var path = require("path");
var bodyParser = require('body-parser');
// create the express app
var app = express();

app.use(bodyParser.urlencoded());
// static content
app.use(express.static(path.join(__dirname, "./static")));
// setting up ejs and our views folder
app.set('views', path.join(__dirname, './views'));
app.set('view engine', 'ejs');
// tell the express app to listen on port 3000
var server = app.listen(3000, function() {
    console.log("listening on port 3000");
})

//we're going to have /routes/index.js handle all of our routing
var route = require('./routes/index.js')(app, server);

Finally my package.json page which contains a list of dependencies I am using:

{
  "name": "epic_button_game",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1",
    "start": "node server.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "ejs": "^2.5.5",
    "express": "^4.14.1",
    "socket.io": "^1.7.2"
  }
}

Thanks for in advance for any suggestions.


Source: stackoverflow-javascript