javascript
\nvar levelOrder = function(root) {\n    let result = [];\n    currentLevelNodes = [];\n    if(root) \n        currentLevelNodes.push(root);\n    while(currentL
```\nvar levelOrder = function(root) {\n    let result = [];\n    currentLevelNodes = [];\n    if(root) \n        currentLevelNodes.push(root);\n    while(currentLevelNodes.length > 0) {\n        current = [];\n        let len = currentLevelNodes.length;\n        for (let i = 0; i< len; i++) {\n            let node = currentLevelNodes.shift();\n            current.push(node.val);\n            if(node.left) {\n                currentLevelNodes.push(node.left);\n            }\n            if(node.right) {\n                currentLevelNodes.push(node.right);\n            }\n        }\n        result.push(current);\n    }\n    return result;\n};\n```
[]