title: Javascript if not in dictionary (node.js)
body: <p>Here's the code:</p>
  
  <pre><code>exports.index_post = function(req, res) {
    var nicks = [];
    if (req.body.nick) {
      for (var nick in nicks) {
        if (nick == req.body.nick) {
          res.redirect("/");
        } else {
          nicks.push(req.body.nick)
          req.session.nick = req.body.nick;
          res.redirect("/msg");
          console.log(nicks);
        }
      }
    } else {
      res.redirect("/");
    }
  };
  </code></pre>
  
  <p>What it's meant to do is check if req.body.nick is one of the items in the nicks dictionary, and if if is redirect it back to the root. If it's not in the dictionary, it should add it to the dictionary and set it as a session variable, then redirect to /msg. However, this code doesn't seem to be working for me and instead it causes Express to hang. Could someone tell me what I'm doing wrong? Thanks.</p>