-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
  • 1,944
  • 18
  • 32
Pavel
  • 1,198
  • 2
  • 13
  • 33

1 Answers1

6

You could join an array

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

// returns ********************
adeneo
  • 303,455
  • 27
  • 380
  • 377