Skip to content
Advertisement

How to return a character n times before an element react

I want to add a random amount of characters before an element, repeat that element 20 times, with a diffrent amount of characters before each time. For example:

JavaScript

An example of what I want to return is

  Hello World! This is time 1
   Hello World! This is time 2
         Hello World! This is time 3
     Hello World! This is time 4
………
Each with a diffrent amount of spaces.

Advertisement

Answer

JavaScript
JavaScript

If I have understood correctly, the above code should do the trick.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement