JavaScript solution
\nconst zigzagLevelOrder = (root) => {\n  let res = [];\n\n  const go = (node, lvl) => {\n    if (node == null) return;\n    if (res[lvl] == null) res[lvl] = []
```\nconst zigzagLevelOrder = (root) => {\n  let res = [];\n\n  const go = (node, lvl) => {\n    if (node == null) return;\n    if (res[lvl] == null) res[lvl] = [];\n\n    if (lvl % 2 === 0) {\n      res[lvl].push(node.val);\n    } else {\n      res[lvl].unshift(node.val);\n    }\n\n    go(node.left, lvl + 1);\n    go(node.right, lvl + 1);\n  };\n\n  go(root, 0);\n  return res;\n};\n```\n
['JavaScript']