repeat() - JavaScript

asiddharth94 profile image asiddharth94 ・1 min read

The repeat() is called on a string which takes one argument (number of times the string needs to be repeated) and returns a new string , containing the repetitions of the string on which it was called (argument times), concatenated together.

Note - The argument passed must be non-negative and the new string formed must not overflow the maximum string size.

'#'.repeat(3) returns '###'


markdown guide

So that's how it's done! I tried to do this the Python way and it gave me NaN.