We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Repeat a given string (first argument) num times (second argument). Return an empty string if num is a negative number.
num
function repeatStringNumTimes(str, num) { return Array(num > 0 ? num + 1 : 0).join(str); } repeatStringNumTimes("abc", 3); // returns 'abcabcabc'