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

Smells like JavaScript Community spirit

Introduction to BabelJS

Creating your gRPC service in Nodejs/Typescript 🔥 (Part 2)

Use cases for JavaScript

Firebase with Kotlin : Firebase Cloud Functions [Part 1 of 2]

How to Set Up Import Aliases for Gatsby

Functional Programming in JavaScript (Part-1)

Keeping It Simple: Implementing Edit-in-Place in Angular

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

[Git]Front End Developer Interview Questions [Git]

The Difference Between Javascript ForEach(), Map() and Filter() Array Methods

JavaScript Scope - All you need to know

JavaScript — Object Oriented Programming: Public and Private Members