Basic Algorithm Scripting - Repeat a String Repeat a String

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

function repeatStringNumTimes(str, num) {
 let accumulatedStr ="";

 for (let i =0; i<num;i++)
   accumulatedStr +=str;
 return accumulatedStr;

repeatStringNumTimes("abc", 3);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic Algorithm Scripting - Repeat a String Repeat a String

Link to the challenge:

Hi There

The code is running, what is the issue?

I am having trouble with:

" Repeat a String Repeat a String

Repeat a given string str (first argument) for num times (second argument). Return an empty string if num is not a positive number. For the purpose of this challenge, do not use the built-in .repeat() method. "

So far I have:

function repeatStringNumTimes(str, num) {
let repeatedString = “”;

for (let i = 0; i < 0; i += 1) {
let (repeatedString === repeatedString*(num));
return repeatedString;

I figured I would set the repeatedString equal to itself times whatever num…then the repeated string would repeat as many times as the num’s value. But I know my logic is off.

function repeatStringNumTimes(str, num) {
// ^^^you are not using the str parameter at all
// which holds the string to be repeated n times
let repeatedString = "";

for (let i = 0; i < 0; i += 1) {
// ^^^will this loop ever run?
// is i ever less then 0?
// if this loop never runs any code in this block will also not run
let (repeatedString === repeatedString*(num));
// ^^^the console should be giving you an syntax error for this
// you are using let which is used to declare a variable, but not making a variable
// you cant just * the string like this in javascript to repeat it
// and repeatedString is also just an empty string right now
// and === is a comparison operator
// its not putting the repeated string into your variable
return repeatedString;

Try fixing that for loop first. Then when you get that working try building that string up in your repeatedString variable.