Question: ```
    app.post(' /', urlencodedParser, function(req, res) {
      res.render('load', {data: req.body});
      var token = req.body.token;
      require('./loader.js')
    });

```

How can I provide variable "token" to loader.js?

Answer: 
As Dave suggested, using a stack, I've wrote the code for it:

```
var leftBraces="([{";
var rightBraces=")]}";

function checkBraces(braces) {
  var ok=true;
  var stack=[];
  for(var i=0; i<braces.length && ok; i++) {
    var brace=braces[i];
    if(leftBraces.includes(brace)) stack.push(brace);
    else {
      var leftBrace=stack.pop();
      if(leftBrace==undefined) ok=false;
      else if(leftBraces.indexOf(leftBrace)!=rightBraces.indexOf(brace)) ok=false;
    }
  }
  if(stack.length) ok=false;
  return ok;
}

```

Code assumes only braces (no spaces or other characters).  

I'm using `string.indexOf()` that matches for `leftBraces` and `rightBraces`.  

Also, within the `for` loop, notice the termination part (2nd): `i<braces.length && ok` - doesn't "have to" use the iterator and, if I'm not mistaken, can even be empty...
Here is a simplified solution:

```
let isMatchingBraces = function(str) {
    let stack = [];
    let symbol = {
        '(': ')',
        '[': ']',
        '{': '}'
    };
    for (let i = 0; i < str.length; i += 1) {
        // If character is an opening brace add it to a stack
        if (str[i] === '(' || str[i] === '{' || str[i] === '[') {
            stack.push(str[i]);
        }
        //  If that character is a closing brace, pop from the stack, which will also reduce the length of the stack each time a closing bracket is encountered.
        else {
            let last = stack.pop();
            //If the popped element from the stack, which is the last opening brace doesn’t match the corresponding closing brace in the symbol, then return false
            if (str[i] !== symbol[last]) {
                return false
            };
        }
    }
    // After checking all the brackets of the str, at the end, the stack is not 
    // empty then fail
    if (stack.length !== 0) {
        return false
    };
    return true;
}

```