// http://www.codewars.com/kata/5277c8a221e209d3f6000b56
function validBraces(braces){
  var valid = ["()", "[]", "{}"];
  var stack = [];
  for(var i=0; i<braces.length; i++){
    var ch = braces.charAt(i);
    switch(ch){
      case "(":
      case "[":
      case "{":
        stack.push(ch);
        break;
      case ")":
      case "]":
      case "}":
        var prev = stack.pop();
        if(valid.indexOf(prev+ch)===-1)
          return false;
        break;
    }
  }
  return !stack.length;
}