9 lines
309 B
JavaScript
9 lines
309 B
JavaScript
repeat = function repeat(str, count) {
|
|
if(typeof(count) == "undefined") {
|
|
count =1;
|
|
}
|
|
return count < 1 ? '' : new Array(count + 1).join(str);
|
|
}
|
|
console.log(repeat('Ha!'));
|
|
console.log(repeat('Ha!',2));
|
|
console.log(repeat('Ha!',3));
|