-1

How to create a string from one char with JavaScript?

This is C#.

String text = new String('*',20);

Is there an easy way to do this with JavaScript?

Ajay
  • 2,022
  • 19
  • 33
Pavel
  • 1,278
  • 2
  • 17
  • 34

1 Answers1

6

You could join an array

var text = new Array(20).join('*');

// returns ********************
adeneo
  • 312,895
  • 29
  • 395
  • 388