How to Implement the String Repeat Function in Javascript?

The string repeat function namely, String.prototype.repeat() is available since ECMAScript 6. The String Repeat function is a handy string method that allows you to repeat a source string a …