rurtubia
12/20/2015 - 5:29 AM

My solution to bonfire 10 at FreeCodeCamp Repeat a given string (first argument) n times (second argument). Return an empty string if n is a

My solution to bonfire 10 at FreeCodeCamp Repeat a given string (first argument) n times (second argument). Return an empty string if n is a negative number.

function repeat(str, num) {
  // repeat after me
  //return str;
  var array = [];
  
  for(i=0 ; i < num; i++)
  {
    array.push(str);
    
  }
  return array.join('');
}

repeat("abc", 3);