JavaScript | Height of Binary Tree

Calculate the height of binary tree
var maxDepth = function(root) {
if (root === null) return 0
return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1
};

--

--

--

Working in Walmart as UI Developer | Mentor | React | JavaScript | HTML | CSS

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Brick by Brick: Creating a Brickbreaker style game in JavaScript, CSS, and HTML Pt. 1

migration talks Monthly News / April, 2022

Why Do You Need to Know About Functional Programming?

Getting Started With React: The Fundamentals.

Create your first Angular APP

Create Quotes of the Day app with toggle dark and night mode using Material UI

redux components

Event Loop

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
iAmSonika | www.startlearncoding.com

iAmSonika | www.startlearncoding.com

Working in Walmart as UI Developer | Mentor | React | JavaScript | HTML | CSS

More from Medium

Object Oriented JavaScript

JS | Count vowel from a String

Prototype Inheritance in Javascript

JavaScript Some Key Topics