diff --git a/'RERUN' button b/'RERUN' button new file mode 100644 index 0000000..348a78d --- /dev/null +++ b/'RERUN' button @@ -0,0 +1,15 @@ + +function repeat_string(string, count) + { + if ((string == null) || (count < 0) || (count === Infinity) || (count == null)) + { + return('Error in string or count.'); + } + count = count | 0; // Floor count. + return new Array(count + 1).join(string); + } + +console.log(repeat_string('a', 4)); +console.log(repeat_string('a')); +console.log(repeat_string('a', -2)); +console.log(repeat_string('a', Infinity));