23 lines
412 B
JavaScript
23 lines
412 B
JavaScript
const repeatString = function(string,num) {
|
|
if(num ===0){
|
|
return "";
|
|
}
|
|
else if(num<0){
|
|
return "ERROR";
|
|
}
|
|
else if(num ===1){
|
|
return string;
|
|
}
|
|
else {
|
|
let result = string;
|
|
while(num>1){
|
|
result = result+ string;
|
|
num--;
|
|
}
|
|
return result;
|
|
}
|
|
};
|
|
|
|
// Do not edit below this line
|
|
module.exports = repeatString;
|