Repeat Character Serveral Times in JavaScript
In Markdown, a header can be written as:
|
|
This is a Setext-style headers, which are ‘underlined’ using equal signs (for
first-level headers) and dashes (for second-level headers). In order to
generate those underlined equal signs, a simple loop could be used to repeat
the character =
several times. By the way, it is not necessary to have exact
number of the equal signs as the header length, but it just looks better. But
there is another way:
|
|
It is using the JavaScript Array global object to construct an empty Array
with the specified array length. Clever indeed!