Tower builder algorithm — JavaScript

  • I define the variable stars and assign the return value of the earlier created function passing the index of the loop.
  • I define the variable space and assign the return value of the earlier created function passing the number of floors (subtracting one) divided by 2 (as we need equal spaces on both sides)
  • And I push in into output :

--

--

--

Full Stack Web Developer | antonzaharia.com

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

Recommended from Medium

Error: Cannot find module <path> build-manifest.json masks an underlying issue with Next.js

React Components

How I made a validation library using ES6 Proxy

How to get started with React and redux-toolkit?

The tool everyone from the CSS-in-JS crowd overlooked

My Top React Interview Questions

How to dynamically set a media query?

10 Tips to Make Your Node.js Web App Faster

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
Zaharia Anton

Zaharia Anton

Full Stack Web Developer | antonzaharia.com

More from Medium

Closure in JavaScript

Promises vs SetTimeout | JAVASCRIPT

Recursion — Function Inception

Yet another linked list tutorial in Javascript