Repeat a String Repeat a String - Basic Algorithm Scripting - Free Code Camp

preview_player
Показать описание
In this basic algorithm scripting tutorial we do an exercise called "repeat a string repeat a string". This is another tutorial that makes up a series where I cover the FreeCodeCamp curriculum. Enjoy!
Рекомендации по теме
Комментарии
Автор

Hello Sir Useful Programmer, how are you?
I watched your video and simplified a code a little:
function repeatStringNumTimes(str, num) {
let result = "";
for(let i = 1; i <= num; i++){
result = str + result;
}
return result;
}
setting i=1 eliminates need for use of if statement.
It was a tough challenge and I have not done it for long time. Thing has settled in my mind and all the videos I watched over and over made me doing it straight away LOL. Anyway, thank you for your hard work, I watch your new productions, although that stuff is well above my level. I am now working full time as warehouse operative, so not much time for coding... It never was, as I was looking after my son during lockdown... I have lost all the weight I gained during unemployment though;) All the best!

astratow
Автор

Hello!
Thank you for making this video. They help a lot.

madalinsion
Автор

thank you for helping with Free Code Camp

herrabuk
Автор

Thank you for the videos. Thanks to them I's able to resolve mi first challenge without hint or help.

noelrisco
Автор

I used this and it worked too;

let result = ""
for (let i = num; i > 0; i--) {
result += str
}
return result
}

I've been enjoying your videos and explanations, thanks for all you've done.

isiaqridwanbukola
Автор

HI sir, thanks for making this videos such a great pleasure to you its useful thanks for taking your own time to put these videos I'm beginner it is very useful and enhance the way of thinking to problem-solving technique I understood and simple request kindly put all videos related web designer thank you sir

santhoshsg
Автор

Thank you Mr. Ian I even tested it out on my own by having it repeat RRT 3 times in a row and RRT stands for Registered Respiratory Therapist.
function repeatStringNumTimes(str, num) {
if (num <= 0) {
return "";
}

let result = "";

for (let i = 0; i < num; i += 1) {
result += str;
}

return result;
}

console.log(repeatStringNumTimes("abc", 3));

zken
Автор

With these challenges really not knowing how to start them could I give me some advice how u know what to start with and what to write

paulfanning
Автор

The newest approach is to use native "repeat" function, ex:

"abc".repeat(3) //abcabcabc

jakubzomerfeld
Автор

here's mine. ez

let newstring = ""
for (let i =0; i < num; i++){
newstring += str
}
return newstring;
}

alvirfrancisco
Автор

let result="";
while(num>0){
num--;
result+=str;
}
return result;

falafel
Автор

Thanks a lot :)
Mine was...
function repeatStringNumTimes(str,  num) {
  let returnString = '';


  }

  return returnString;
}

repeatStringNumTimes("abc",  3);

calin
visit shbcf.ru