Return Empty quotes

Tell us what’s happening:
I’m so close to finishing this, but i’ve been stuck on this technical thing for like a week, and i’ve looked it up a bunch of times on google. but i can find how to return empty quotes i even looked at the answer for the challenge and did what it said and still when i run the test, it doesn’t work.

Your code so far


function repeatStringNumTimes(str, num) {
if ( num <= 0){
 let blank = " ";
  return blank;
} else {
  let arr = [];
  for (let i = 0; i < num - 1; i++){
  let rob = str.substr(0);
  arr.push(rob);}    
  let rot = arr.join("");
  let tot = str.concat(rot);
  return tot

} 
}

console.log(repeatStringNumTimes("*", 8));

  //i can turn it into an array then have a for loop run as long as its smaller than num. And if its smaller i'll have be pushed into the concat bc i'm pretty sure u can concat arrays as well
  // the problem now is that the answer is given with a comma instead of being join and the only way to fix that is by concating so i can concat x amount of times with an even number and then add one concat when its odd and then make a special case when it for it to run once. But i know ther is a better way to do this than this
  

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36.

Challenge: Repeat a String Repeat a String

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string

You’ve added a space there my guy which counts as a non empty string.

Annotation 2020-02-10 233803

2 Likes

i know it would be some really small and specify thing, regardless thank u for the help