Recursion explained

Illustrative flowchart of our recursive function

Our main function isn’t happy until our y value equals 0. To evaluate this condition it runs through a series of if statements that, if triggered, will modify the value of y, adding or subtracting accordingly. Our function is called over and over again until it is satisfied. Eventually our function calls itself again a last time, having reached the final value of x = 0 and y = 0, it can finally rest.

--

--

--

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

Recommended from Medium

How to Add Infinite Scrolling to Your React App

Top React Hooks — Forms and Forward Refs

JavaScript Tips — Parsing URLs, Reading Files, and More

View component’s multiple states (active, focus, hover, disable, error, …) as a single row in…

“Computer! Tea, Earl Grey, Hot”: Offline Voice on NodeJS

Contact Form With React: Using Emailjs

Developing Vue Apps with the Quasar Library — Sticky Table and Cell Separators

Introduction to Request Body Validation in Express Apps with express-validator

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
Gabriel Vazquez

Gabriel Vazquez

More from Medium

CS371p Spring 2022: Lisa Alexander

Bias in Algorithms

Basics of Mongoose

How does Human Pose Estimation works