This is another very basic and easy challenge for javascript beginners to repeat a string for a certain number of times.
|
function repeatString(msg, times){ times = Math.abs(times); return msg.repeat(times); } const result = repeatString('Hello World', -4); console.log(result); |